diff --git a/.fern/metadata.json b/.fern/metadata.json index eb42e81..104acf4 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,16 +1,16 @@ { - "cliVersion": "5.89.4", + "cliVersion": "5.143.0", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "4.17.0", + "generatorVersion": "4.23.1", "generatorConfig": { "publish-to": "central", "client-class-name": "CatchAllApi", "package-prefix": "com.newscatcher.catchall" }, - "originGitCommit": "3f4bdad0a71333b0f9fb6f42d44d174f2e40167b", + "originGitCommit": "6ef7448ab601e5b372caec45717b0390a4150d2c", "originGitCommitIsDirty": true, "invokedBy": "ci", "requestedVersion": "AUTO", "ciProvider": "unknown", - "sdkVersion": "3.0.4" + "sdkVersion": "3.0.5" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock index c1012b1..39d42b2 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -12,5 +12,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-java-sdk: 4.17.0 -current_generation: 5855dcc73133889ded68524f74e61af3cf971e68 + - commit_sha: b2be01153a63a951ba3db45c87ebd0d44d6b696d + tree_hash: 4c2185090c5ed162b8fe1fba43dd81bd4414f92d + timestamp: 2026-09-30T10:10:10.893Z + cli_version: unknown + generator_versions: + fernapi/fern-java-sdk: 4.23.1 +current_generation: b2be01153a63a951ba3db45c87ebd0d44d6b696d patches: [] diff --git a/README.md b/README.md index 3222a2d..a90bbfd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Add the dependency in your `build.gradle` file: ```groovy dependencies { - implementation 'com.newscatcherapi:newscatcher-catchall-sdk:3.0.4' + implementation 'com.newscatcherapi:newscatcher-catchall-sdk:3.0.5' } ``` @@ -47,7 +47,7 @@ Add the dependency in your `pom.xml` file: com.newscatcherapi newscatcher-catchall-sdk - 3.0.4 + 3.0.5 ``` @@ -267,3 +267,4 @@ On the other hand, contributions to the README are always very welcome! + diff --git a/build.gradle b/build.gradle index f09ee71..20f4a1b 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ java { group = 'com.newscatcherapi' -version = '3.0.4' +version = '3.0.5' jar { dependsOn(":generatePomFileForMavenPublication") @@ -88,7 +88,7 @@ publishing { maven(MavenPublication) { groupId = 'com.newscatcherapi' artifactId = 'newscatcher-catchall-sdk' - version = '3.0.4' + version = '3.0.5' from components.java pom { name = 'newscatcher' diff --git a/changelog.md b/changelog.md index 48e8ee7..7d99624 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +## [3.0.5] - 2026-09-30 + ## [3.0.4] - 2026-08-04 ## 2.0.0 - 2026-05-19 diff --git a/reference.md b/reference.md index cb1e7b8..38aae03 100644 --- a/reference.md +++ b/reference.md @@ -382,7 +382,7 @@ Job processing mode. **connectedDatasetIds:** `Optional>` -Dataset IDs to connect to the job. When provided, this enables Company Watchlist mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use `ed_score_min`. +Dataset IDs to connect to the job. When provided, this enables Company Monitors mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use `ed_score_min`. The dataset must have `latest_status: ready` before the job is submitted. Submitting with a non-existent or inaccessible dataset ID returns `400`. @@ -422,7 +422,7 @@ Only valid when `connected_dataset_ids` is set; otherwise ignored. Records where **fetchAllWatchlistNews:** `Optional` -When true, retrieves all news for connected Company Watchlist entities +When true, retrieves all news for connected Company Monitors entities without topic filtering. Requires connected_dataset_ids to be set. @@ -438,6 +438,20 @@ events where the entity is a direct actor. `mention` keeps only events where the entity is merely referenced. Only relevant when connected_dataset_ids is set. + + + +
+
+ +**sourceGroups:** `Optional>` + +Slugs of source groups to scope fetching to their curated domain allowlists. + +Source groups are named domain lists maintained by NewsCatcher (for example "Top 100 US Finance"). Retrieve the groups available to your organization with [List source groups](https://www.newscatcherapi.com/docs/web-search-api/api-reference/jobs/list-source-groups). + +Domains are resolved when the job runs, so a group's current membership always applies. Maximum 20 groups per job. An unknown or inaccessible slug is rejected at submit time. +
@@ -774,8 +788,82 @@ client.jobs().deleteJob( -## Monitors -
client.monitors.listMonitors() -> ListMonitorsResponseDto +
client.jobs.listSourceGroups() -> ListSourceGroupsResponseDto +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of source groups visible to your organization. + +A source group is a named, curated domain allowlist maintained by NewsCatcher — for +example "Top 100 US Finance". Pass a group's `slug` in `source_groups` when creating +a job to scope article fetching to that group's domains, instead of maintaining a +long domain list yourself. + +The response covers public groups plus any restricted groups your organization has +been granted access to. Each entry returns `slug`, `name`, and `description`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.jobs().listSourceGroups( + ListSourceGroupsRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — Page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — Number of source groups per page. + +
+
+
+
+ + +
+
+
+ +## Event Monitors +
client.eventMonitors.listMonitors() -> ListMonitorsResponseDto
@@ -787,7 +875,7 @@ client.jobs().deleteJob(
-Returns all monitors created by the authenticated user. +Returns all event monitors created by the authenticated user.
@@ -802,7 +890,7 @@ Returns all monitors created by the authenticated user.
```java -client.monitors().listMonitors( +client.eventMonitors().listMonitors( ListMonitorsRequest .builder() .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") @@ -866,7 +954,7 @@ client.monitors().listMonitors(
-
client.monitors.createMonitor(request) -> CreateMonitorResponseDto +
client.eventMonitors.createMonitor(request) -> CreateMonitorResponseDto
@@ -878,7 +966,7 @@ client.monitors().listMonitors(
-Create a scheduled monitor based on a reference job. +Create a scheduled event monitor based on a reference job.
@@ -893,7 +981,7 @@ Create a scheduled monitor based on a reference job.
```java -client.monitors().createMonitor( +client.eventMonitors().createMonitor( CreateMonitorRequestDto .builder() .referenceJobId("5f0c9087-85cb-4917-b3c7-e5a5eff73a0c") @@ -926,7 +1014,7 @@ client.monitors().createMonitor( Job ID to use as template for scheduled runs. Defines the query, validators, and enrichments used for each scheduled run. -If [`backfill`](https://www.newscatcherapi.com/docs/web-search-api/api-reference/monitors/create-monitor#body-backfill) is true, the job's `end_date` must be within the last 7 days. +If [`backfill`](https://www.newscatcherapi.com/docs/web-search-api/api-reference/event-monitors/create-monitor#body-backfill) is true, the job's `end_date` must be within the last 7 days.
@@ -934,7 +1022,7 @@ If [`backfill`](https://www.newscatcherapi.com/docs/web-search-api/api-reference
-**schedule:** `String` — Monitor schedule in plain text format. Minimum frequency depends on your plan. +**schedule:** `String` — Event monitor schedule in plain text format. Minimum frequency depends on your plan.
@@ -959,7 +1047,7 @@ If the schedule includes a timezone abbreviation (for example, `"every day at 9a IDs of centralized webhooks to notify on each run completion. Passing IDs here is equivalent to calling `POST /catchAll/webhooks/{webhook_id}/resources` for each ID after creation. -Maximum 5 per monitor. +Maximum 5 per event monitor. @@ -967,7 +1055,7 @@ Maximum 5 per monitor.
-**limit:** `Optional` — Maximum number of records per monitor run. If not provided, defaults to the plan limit. +**limit:** `Optional` — Maximum number of records per event monitor run. If not provided, defaults to the plan limit.
@@ -987,7 +1075,7 @@ If false, no gap filling occurs and the first run uses the current cron window o
-**projectId:** `Optional` — Project to assign this monitor to. The monitor appears in the project's resource list after creation. +**projectId:** `Optional` — Project to assign this event monitor to. The event monitor appears in the project's resource list after creation.
@@ -999,7 +1087,7 @@ If false, no gap filling occurs and the first run uses the current cron window o
-
client.monitors.pullMonitorResults(monitorId) -> PullMonitorResponseDto +
client.eventMonitors.pullMonitorResults(monitorId) -> PullMonitorResponseDto
@@ -1011,7 +1099,7 @@ If false, no gap filling occurs and the first run uses the current cron window o
-Retrieve aggregated results from all jobs executed by a monitor. +Retrieve aggregated results from all jobs executed by an event monitor.
@@ -1026,7 +1114,7 @@ Retrieve aggregated results from all jobs executed by a monitor.
```java -client.monitors().pullMonitorResults( +client.eventMonitors().pullMonitorResults( "monitor_id", PullMonitorResultsRequest .builder() @@ -1046,7 +1134,7 @@ client.monitors().pullMonitorResults(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1058,7 +1146,7 @@ client.monitors().pullMonitorResults(
-
client.monitors.pullMonitorResultsCsv(monitorId) -> String +
client.eventMonitors.pullMonitorResultsCsv(monitorId) -> String
@@ -1072,7 +1160,7 @@ client.monitors().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.
@@ -1087,7 +1175,7 @@ If the monitor's reference job used connected entity datasets, connected entitie
```java -client.monitors().pullMonitorResultsCsv( +client.eventMonitors().pullMonitorResultsCsv( "monitor_id", PullMonitorResultsCsvRequest .builder() @@ -1107,7 +1195,7 @@ client.monitors().pullMonitorResultsCsv(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1119,7 +1207,7 @@ client.monitors().pullMonitorResultsCsv(
-
client.monitors.listMonitorJobs(monitorId) -> ListMonitorJobsResponse +
client.eventMonitors.listMonitorJobs(monitorId) -> ListMonitorJobsResponse
@@ -1131,7 +1219,7 @@ client.monitors().pullMonitorResultsCsv(
-Return all jobs executed by a monitor. +Return all jobs executed by an event monitor.
@@ -1146,7 +1234,7 @@ Return all jobs executed by a monitor.
```java -client.monitors().listMonitorJobs( +client.eventMonitors().listMonitorJobs( "monitor_id", ListMonitorJobsRequest .builder() @@ -1166,7 +1254,7 @@ client.monitors().listMonitorJobs(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1186,7 +1274,7 @@ client.monitors().listMonitorJobs(
-
client.monitors.getMonitorStatusHistory(monitorId) -> MonitorStatusHistoryResponseDto +
client.eventMonitors.getMonitorStatusHistory(monitorId) -> MonitorStatusHistoryResponseDto
@@ -1198,7 +1286,7 @@ client.monitors().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.
@@ -1213,7 +1301,7 @@ Returns the full execution history of a monitor as a list of status entries, ord
```java -client.monitors().getMonitorStatusHistory( +client.eventMonitors().getMonitorStatusHistory( "monitor_id", GetMonitorStatusHistoryRequest .builder() @@ -1233,7 +1321,7 @@ client.monitors().getMonitorStatusHistory(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1245,7 +1333,7 @@ client.monitors().getMonitorStatusHistory(
-
client.monitors.enableMonitor(monitorId, request) -> EnableMonitorResponse +
client.eventMonitors.enableMonitor(monitorId, request) -> EnableMonitorResponse
@@ -1257,7 +1345,7 @@ client.monitors().getMonitorStatusHistory(
-Resume scheduled job execution for a monitor. +Resume scheduled job execution for an event monitor.
@@ -1272,7 +1360,7 @@ Resume scheduled job execution for a monitor.
```java -client.monitors().enableMonitor( +client.eventMonitors().enableMonitor( "monitor_id", EnableMonitorRequestDto .builder() @@ -1293,7 +1381,7 @@ client.monitors().enableMonitor(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1317,7 +1405,7 @@ If false, no gap filling occurs and the first run uses the current cron window o
-
client.monitors.disableMonitor(monitorId) -> DisableMonitorResponse +
client.eventMonitors.disableMonitor(monitorId) -> DisableMonitorResponse
@@ -1329,7 +1417,7 @@ If false, no gap filling occurs and the first run uses the current cron window o
-Stop scheduled job execution for a monitor. +Stop scheduled job execution for an event monitor.
@@ -1344,7 +1432,7 @@ Stop scheduled job execution for a monitor.
```java -client.monitors().disableMonitor( +client.eventMonitors().disableMonitor( "monitor_id", DisableMonitorRequest .builder() @@ -1364,7 +1452,7 @@ client.monitors().disableMonitor(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1376,7 +1464,7 @@ client.monitors().disableMonitor(
-
client.monitors.deleteMonitor(monitorId) -> DeleteMonitorResponseDto +
client.eventMonitors.deleteMonitor(monitorId) -> DeleteMonitorResponseDto
@@ -1388,14 +1476,14 @@ client.monitors().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. +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 monitor returns `200`. +Deleting an already-deleted event monitor returns `200`.
@@ -1410,7 +1498,7 @@ Deleting an already-deleted monitor returns `200`.
```java -client.monitors().deleteMonitor( +client.eventMonitors().deleteMonitor( "monitor_id", DeleteMonitorRequest .builder() @@ -1430,7 +1518,7 @@ client.monitors().deleteMonitor(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1442,7 +1530,7 @@ client.monitors().deleteMonitor(
-
client.monitors.updateMonitor(monitorId, request) -> UpdateMonitorResponseDto +
client.eventMonitors.updateMonitor(monitorId, request) -> UpdateMonitorResponseDto
@@ -1454,7 +1542,12 @@ client.monitors().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.
@@ -1469,7 +1562,7 @@ Update the webhook configuration for an existing monitor.
```java -client.monitors().updateMonitor( +client.eventMonitors().updateMonitor( "monitor_id", UpdateMonitorRequestDto .builder() @@ -1494,7 +1587,7 @@ client.monitors().updateMonitor(
-**monitorId:** `String` — Monitor identifier. +**monitorId:** `String` — Event monitor identifier.
@@ -1504,7 +1597,7 @@ client.monitors().updateMonitor( **webhookIds:** `Optional>` -Updated list of centralized webhook IDs for this monitor. +Updated list of centralized webhook IDs for this event monitor. Replaces all existing webhook assignments. Pass an empty array `[]` to clear all assignments. Omit to leave existing assignments unchanged. @@ -1514,7 +1607,34 @@ Replaces all existing webhook assignments. Pass an empty array `[]` to clear all
-**limit:** `Optional` — Updated maximum number of records per monitor run. +**limit:** `Optional` — Updated maximum number of records per event monitor run. + +
+
+ +
+
+ +**schedule:** `Optional` + +New natural-language schedule that replaces the event monitor's current +schedule. Examples: `every day at 9 AM`, `every Monday at 6 PM EST`. + +Omit to keep the current schedule. The new schedule takes effect from the +next scheduler reload, and the old schedule stops firing. Returns `422` if +the text can't be parsed or runs would be spaced too closely. + +
+
+ +
+
+ +**timezone:** `Optional` + +IANA timezone for the new schedule (for example, `America/New_York`). +A timezone included in the `schedule` text takes precedence. Ignored if +`schedule` is not set.
@@ -1557,6 +1677,7 @@ Returns a paginated list of webhooks belonging to the organization. client.webhooks().listWebhooks( ListWebhooksRequest .builder() + .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") .build() ); ``` @@ -1591,6 +1712,14 @@ client.webhooks().listWebhooks( **search:** `Optional` — Filter results by text (case-insensitive substring match). +
+
+ +
+
+ +**projectId:** `Optional` — Filter results to resources belonging to this project. +
@@ -1833,7 +1962,7 @@ client.webhooks().getWebhook( Permanently deletes a webhook and removes all resource assignments. -Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone. +Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone. @@ -2035,7 +2164,7 @@ client.webhooks().updateWebhook( Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. -Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor. +Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor. @@ -2194,7 +2323,7 @@ client.webhooks().listWebhookResources(
-Attaches a job, monitor, or monitor group to the webhook. When the +Attaches a job, event monitor, or event monitor group to the webhook. When the resource completes, the webhook receives a delivery. A single webhook can be assigned to multiple resources. Each resource @@ -2447,7 +2576,7 @@ client.webhooks().listWebhooksForResource(
Manually dispatches a webhook delivery for a resource on demand, without -waiting for the next job or monitor cycle. +waiting for the next job or event monitor cycle. Use this to re-deliver results after a failed delivery, replay a specific job's results, or validate a webhook against live data. The webhook must @@ -2647,6 +2776,7 @@ client.entities().listEntities( ListEntitiesRequest .builder() .search("NewsCatcher") + .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") .build() ); ``` @@ -2713,6 +2843,14 @@ client.entities().listEntities( **sortOrder:** `Optional` +
+
+ +
+
+ +**projectId:** `Optional` — Filter results to resources belonging to this project. +
@@ -4277,7 +4415,7 @@ client.projects().deleteProject( **deleteResources:** `Optional` -If true, permanently deletes all resources (jobs, monitors, datasets, monitor groups) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted. +If true, permanently deletes all resources (jobs, event monitors, datasets, event monitor groups) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted. Webhooks are never deleted by either setting — they are only detached from the project. diff --git a/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java b/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java index 216ce3f..37d1454 100644 --- a/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java +++ b/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java @@ -7,19 +7,19 @@ import com.newscatcher.catchall.core.Suppliers; import com.newscatcher.catchall.resources.datasets.AsyncDatasetsClient; import com.newscatcher.catchall.resources.entities.AsyncEntitiesClient; +import com.newscatcher.catchall.resources.eventmonitors.AsyncEventMonitorsClient; import com.newscatcher.catchall.resources.jobs.AsyncJobsClient; import com.newscatcher.catchall.resources.meta.AsyncMetaClient; -import com.newscatcher.catchall.resources.monitors.AsyncMonitorsClient; import com.newscatcher.catchall.resources.projects.AsyncProjectsClient; import com.newscatcher.catchall.resources.webhooks.AsyncWebhooksClient; import java.util.function.Supplier; -public class AsyncCatchAllApi { +public class AsyncCatchAllApi implements AutoCloseable { protected final ClientOptions clientOptions; protected final Supplier jobsClient; - protected final Supplier monitorsClient; + protected final Supplier eventMonitorsClient; protected final Supplier webhooksClient; @@ -34,7 +34,7 @@ public class AsyncCatchAllApi { public AsyncCatchAllApi(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); - this.monitorsClient = Suppliers.memoize(() -> new AsyncMonitorsClient(clientOptions)); + this.eventMonitorsClient = Suppliers.memoize(() -> new AsyncEventMonitorsClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new AsyncWebhooksClient(clientOptions)); this.entitiesClient = Suppliers.memoize(() -> new AsyncEntitiesClient(clientOptions)); this.datasetsClient = Suppliers.memoize(() -> new AsyncDatasetsClient(clientOptions)); @@ -46,8 +46,8 @@ public AsyncJobsClient jobs() { return this.jobsClient.get(); } - public AsyncMonitorsClient monitors() { - return this.monitorsClient.get(); + public AsyncEventMonitorsClient eventMonitors() { + return this.eventMonitorsClient.get(); } public AsyncWebhooksClient webhooks() { @@ -70,6 +70,16 @@ public AsyncMetaClient meta() { return this.metaClient.get(); } + /** + * Releases resources owned by this client: any WebSocket clients still connected through + * it are disconnected first, then the SDK-owned HTTP client is shut down. See + * {@code ClientOptions.close()} for what is and is not released. + */ + @Override + public void close() { + this.clientOptions.close(); + } + public static AsyncCatchAllApiBuilder builder() { return new AsyncCatchAllApiBuilder(); } diff --git a/src/main/java/com/newscatcher/catchall/CatchAllApi.java b/src/main/java/com/newscatcher/catchall/CatchAllApi.java index f76e185..6c7c538 100644 --- a/src/main/java/com/newscatcher/catchall/CatchAllApi.java +++ b/src/main/java/com/newscatcher/catchall/CatchAllApi.java @@ -7,19 +7,19 @@ import com.newscatcher.catchall.core.Suppliers; import com.newscatcher.catchall.resources.datasets.DatasetsClient; import com.newscatcher.catchall.resources.entities.EntitiesClient; +import com.newscatcher.catchall.resources.eventmonitors.EventMonitorsClient; import com.newscatcher.catchall.resources.jobs.JobsClient; import com.newscatcher.catchall.resources.meta.MetaClient; -import com.newscatcher.catchall.resources.monitors.MonitorsClient; import com.newscatcher.catchall.resources.projects.ProjectsClient; import com.newscatcher.catchall.resources.webhooks.WebhooksClient; import java.util.function.Supplier; -public class CatchAllApi { +public class CatchAllApi implements AutoCloseable { protected final ClientOptions clientOptions; protected final Supplier jobsClient; - protected final Supplier monitorsClient; + protected final Supplier eventMonitorsClient; protected final Supplier webhooksClient; @@ -34,7 +34,7 @@ public class CatchAllApi { public CatchAllApi(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions)); - this.monitorsClient = Suppliers.memoize(() -> new MonitorsClient(clientOptions)); + this.eventMonitorsClient = Suppliers.memoize(() -> new EventMonitorsClient(clientOptions)); this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions)); this.entitiesClient = Suppliers.memoize(() -> new EntitiesClient(clientOptions)); this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions)); @@ -46,8 +46,8 @@ public JobsClient jobs() { return this.jobsClient.get(); } - public MonitorsClient monitors() { - return this.monitorsClient.get(); + public EventMonitorsClient eventMonitors() { + return this.eventMonitorsClient.get(); } public WebhooksClient webhooks() { @@ -70,6 +70,16 @@ public MetaClient meta() { return this.metaClient.get(); } + /** + * Releases resources owned by this client: any WebSocket clients still connected through + * it are disconnected first, then the SDK-owned HTTP client is shut down. See + * {@code ClientOptions.close()} for what is and is not released. + */ + @Override + public void close() { + this.clientOptions.close(); + } + public static CatchAllApiBuilder builder() { return new CatchAllApiBuilder(); } diff --git a/src/main/java/com/newscatcher/catchall/core/ClientOptions.java b/src/main/java/com/newscatcher/catchall/core/ClientOptions.java index 4eaa689..a831b43 100644 --- a/src/main/java/com/newscatcher/catchall/core/ClientOptions.java +++ b/src/main/java/com/newscatcher/catchall/core/ClientOptions.java @@ -3,10 +3,14 @@ */ package com.newscatcher.catchall.core; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import okhttp3.OkHttpClient; @@ -19,6 +23,12 @@ public final class ClientOptions { private final OkHttpClient httpClient; + private final boolean ownsHttpClient; + + private final AtomicBoolean closed; + + private final Set openWebSockets; + private final int timeout; private final int maxRetries; @@ -36,6 +46,9 @@ private ClientOptions( Map headers, Map> headerSuppliers, OkHttpClient httpClient, + boolean ownsHttpClient, + AtomicBoolean closed, + Set openWebSockets, int timeout, int maxRetries, Optional initialRetryDelayMillis, @@ -47,14 +60,17 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.newscatcherapi.newscatcher-catchall-sdk/3.0.4"); + put("User-Agent", "com.newscatcherapi.newscatcher-catchall-sdk/3.0.5"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.newscatcherapi:newscatcher-catchall-sdk"); - put("X-Fern-SDK-Version", "3.0.4"); + put("X-Fern-SDK-Version", "3.0.5"); } }); this.headerSuppliers = headerSuppliers; this.httpClient = httpClient; + this.ownsHttpClient = ownsHttpClient; + this.closed = closed; + this.openWebSockets = openWebSockets; this.timeout = timeout; this.maxRetries = maxRetries; this.initialRetryDelayMillis = initialRetryDelayMillis; @@ -118,6 +134,68 @@ public Optional 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 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, DeleteMonitorRequest request) { @@ -818,12 +840,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 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, DeleteMonitorRequest request, RequestOptions requestOptions) { @@ -886,14 +908,22 @@ public CatchAllApiHttpResponse 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 CatchAllApiHttpResponse 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 CatchAllApiHttpResponse updateMonitor( String monitorId, RequestOptions requestOptions) { @@ -901,7 +931,11 @@ public CatchAllApiHttpResponse 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 CatchAllApiHttpResponse updateMonitor( String monitorId, UpdateMonitorRequestDto request) { @@ -909,7 +943,11 @@ public CatchAllApiHttpResponse 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 CatchAllApiHttpResponse updateMonitor( String monitorId, UpdateMonitorRequestDto request, RequestOptions requestOptions) { @@ -959,6 +997,9 @@ public CatchAllApiHttpResponse updateMonitor( } 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/monitors/requests/CreateMonitorRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/CreateMonitorRequestDto.java similarity index 87% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/CreateMonitorRequestDto.java index e0c484c..18752e4 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/CreateMonitorRequestDto.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -59,7 +59,7 @@ private CreateMonitorRequestDto( /** * @return Job ID to use as template for scheduled runs. Defines the query, validators, and enrichments used for each scheduled run. - *

If backfill is true, the job's end_date must be within the last 7 days.

+ *

If backfill is true, the job's end_date must be within the last 7 days.

*/ @JsonProperty("reference_job_id") public String getReferenceJobId() { @@ -67,7 +67,7 @@ public String getReferenceJobId() { } /** - * @return Monitor schedule in plain text format. Minimum frequency depends on your plan. + * @return Event monitor schedule in plain text format. Minimum frequency depends on your plan. */ @JsonProperty("schedule") public String getSchedule() { @@ -87,7 +87,7 @@ public Optional getTimezone() { * @return IDs of centralized webhooks to notify on each run completion. * Passing IDs here is equivalent to calling * POST /catchAll/webhooks/{webhook_id}/resources for each ID after creation. - * Maximum 5 per monitor. + * Maximum 5 per event monitor. */ @JsonProperty("webhook_ids") public Optional> getWebhookIds() { @@ -95,7 +95,7 @@ public Optional> getWebhookIds() { } /** - * @return Maximum number of records per monitor run. If not provided, defaults to the plan limit. + * @return Maximum number of records per event monitor run. If not provided, defaults to the plan limit. */ @JsonProperty("limit") public Optional getLimit() { @@ -112,7 +112,7 @@ public Optional getBackfill() { } /** - * @return Project to assign this monitor to. The monitor appears in the project's resource list after creation. + * @return Project to assign this event monitor to. The event monitor appears in the project's resource list after creation. */ @JsonProperty("project_id") public Optional getProjectId() { @@ -164,7 +164,7 @@ public static ReferenceJobIdStage builder() { public interface ReferenceJobIdStage { /** *

Job ID to use as template for scheduled runs. Defines the query, validators, and enrichments used for each scheduled run.

- *

If backfill is true, the job's end_date must be within the last 7 days.

+ *

If backfill is true, the job's end_date must be within the last 7 days.

*/ ScheduleStage referenceJobId(@NotNull String referenceJobId); @@ -173,7 +173,7 @@ public interface ReferenceJobIdStage { public interface ScheduleStage { /** - *

Monitor schedule in plain text format. Minimum frequency depends on your plan.

+ *

Event monitor schedule in plain text format. Minimum frequency depends on your plan.

*/ _FinalStage schedule(@NotNull String schedule); } @@ -197,14 +197,14 @@ public interface _FinalStage { *

IDs of centralized webhooks to notify on each run completion. * Passing IDs here is equivalent to calling * POST /catchAll/webhooks/{webhook_id}/resources for each ID after creation. - * Maximum 5 per monitor.

+ * Maximum 5 per event monitor.

*/ _FinalStage webhookIds(Optional> webhookIds); _FinalStage webhookIds(List webhookIds); /** - *

Maximum number of records per monitor run. If not provided, defaults to the plan limit.

+ *

Maximum number of records per event monitor run. If not provided, defaults to the plan limit.

*/ _FinalStage limit(Optional limit); @@ -219,7 +219,7 @@ public interface _FinalStage { _FinalStage backfill(Boolean backfill); /** - *

Project to assign this monitor to. The monitor appears in the project's resource list after creation.

+ *

Project to assign this event monitor to. The event monitor appears in the project's resource list after creation.

*/ _FinalStage projectId(Optional projectId); @@ -261,7 +261,7 @@ public Builder from(CreateMonitorRequestDto other) { /** *

Job ID to use as template for scheduled runs. Defines the query, validators, and enrichments used for each scheduled run.

- *

If backfill is true, the job's end_date must be within the last 7 days.

+ *

If backfill is true, the job's end_date must be within the last 7 days.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -272,7 +272,7 @@ public ScheduleStage referenceJobId(@NotNull String referenceJobId) { } /** - *

Monitor schedule in plain text format. Minimum frequency depends on your plan.

+ *

Event monitor schedule in plain text format. Minimum frequency depends on your plan.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -283,7 +283,7 @@ public _FinalStage schedule(@NotNull String schedule) { } /** - *

Project to assign this monitor to. The monitor appears in the project's resource list after creation.

+ *

Project to assign this event monitor to. The event monitor appears in the project's resource list after creation.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -293,7 +293,7 @@ public _FinalStage projectId(String projectId) { } /** - *

Project to assign this monitor to. The monitor appears in the project's resource list after creation.

+ *

Project to assign this event monitor to. The event monitor appears in the project's resource list after creation.

*/ @java.lang.Override @JsonSetter(value = "project_id", nulls = Nulls.SKIP) @@ -325,7 +325,7 @@ public _FinalStage backfill(Optional backfill) { } /** - *

Maximum number of records per monitor run. If not provided, defaults to the plan limit.

+ *

Maximum number of records per event monitor run. If not provided, defaults to the plan limit.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -335,7 +335,7 @@ public _FinalStage limit(Integer limit) { } /** - *

Maximum number of records per monitor run. If not provided, defaults to the plan limit.

+ *

Maximum number of records per event monitor run. If not provided, defaults to the plan limit.

*/ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) @@ -348,7 +348,7 @@ public _FinalStage limit(Optional limit) { *

IDs of centralized webhooks to notify on each run completion. * Passing IDs here is equivalent to calling * POST /catchAll/webhooks/{webhook_id}/resources for each ID after creation. - * Maximum 5 per monitor.

+ * Maximum 5 per event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -361,7 +361,7 @@ public _FinalStage webhookIds(List webhookIds) { *

IDs of centralized webhooks to notify on each run completion. * Passing IDs here is equivalent to calling * POST /catchAll/webhooks/{webhook_id}/resources for each ID after creation. - * Maximum 5 per monitor.

+ * Maximum 5 per event monitor.

*/ @java.lang.Override @JsonSetter(value = "webhook_ids", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/DeleteMonitorRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DeleteMonitorRequest.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/DeleteMonitorRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DeleteMonitorRequest.java index fe58f8d..5197b10 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/DeleteMonitorRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DeleteMonitorRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/DisableMonitorRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DisableMonitorRequest.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/DisableMonitorRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DisableMonitorRequest.java index 5e5d725..3c8fb86 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/DisableMonitorRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/DisableMonitorRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/EnableMonitorRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/EnableMonitorRequestDto.java similarity index 98% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/EnableMonitorRequestDto.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/EnableMonitorRequestDto.java index d72179f..03e785b 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/EnableMonitorRequestDto.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/EnableMonitorRequestDto.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/GetMonitorStatusHistoryRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/GetMonitorStatusHistoryRequest.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/GetMonitorStatusHistoryRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/GetMonitorStatusHistoryRequest.java index d5f1418..23f51e6 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/GetMonitorStatusHistoryRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/GetMonitorStatusHistoryRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorJobsRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorJobsRequest.java similarity index 95% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorJobsRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorJobsRequest.java index 5575d5f..e2988b7 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorJobsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorJobsRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.catchall.core.ObjectMappers; -import com.newscatcher.catchall.resources.monitors.types.ListMonitorJobsRequestSort; +import com.newscatcher.catchall.resources.eventmonitors.types.ListMonitorJobsRequestSort; import java.util.HashMap; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorsRequest.java similarity index 99% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorsRequest.java index 9f19155..7a87813 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/ListMonitorsRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsCsvRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsCsvRequest.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsCsvRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsCsvRequest.java index aaa220b..9fb8442 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsCsvRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsCsvRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsRequest.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsRequest.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsRequest.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsRequest.java index a6ef92a..9f59e7b 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/PullMonitorResultsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/PullMonitorResultsRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.requests; +package com.newscatcher.catchall.resources.eventmonitors.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; diff --git a/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/UpdateMonitorRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/UpdateMonitorRequestDto.java new file mode 100644 index 0000000..2710df8 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/requests/UpdateMonitorRequestDto.java @@ -0,0 +1,261 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.eventmonitors.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.Nullable; +import com.newscatcher.catchall.core.NullableNonemptyFilter; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateMonitorRequestDto.Builder.class) +public final class UpdateMonitorRequestDto { + private final Optional> webhookIds; + + private final Optional limit; + + private final Optional schedule; + + private final Optional timezone; + + private final Map additionalProperties; + + private UpdateMonitorRequestDto( + Optional> webhookIds, + Optional limit, + Optional schedule, + Optional timezone, + Map additionalProperties) { + this.webhookIds = webhookIds; + this.limit = limit; + this.schedule = schedule; + this.timezone = timezone; + this.additionalProperties = additionalProperties; + } + + /** + * @return Updated list of centralized webhook IDs for this event monitor. + *

Replaces all existing webhook assignments. Pass an empty array [] to clear all assignments. Omit to leave existing assignments unchanged.

+ */ + @JsonProperty("webhook_ids") + public Optional> getWebhookIds() { + return webhookIds; + } + + /** + * @return Updated maximum number of records per event monitor run. + */ + @JsonProperty("limit") + public Optional getLimit() { + return limit; + } + + /** + * @return New natural-language schedule that replaces the event monitor's current + * schedule. Examples: every day at 9 AM, every Monday at 6 PM EST. + *

Omit to keep the current schedule. The new schedule takes effect from the + * next scheduler reload, and the old schedule stops firing. Returns 422 if + * the text can't be parsed or runs would be spaced too closely.

+ */ + @JsonIgnore + public Optional getSchedule() { + if (schedule == null) { + return Optional.empty(); + } + return schedule; + } + + /** + * @return IANA timezone for the new schedule (for example, America/New_York). + * A timezone included in the schedule text takes precedence. Ignored if + * schedule is not set. + */ + @JsonIgnore + public Optional getTimezone() { + if (timezone == null) { + return Optional.empty(); + } + return timezone; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("schedule") + private Optional _getSchedule() { + return schedule; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("timezone") + private Optional _getTimezone() { + return timezone; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateMonitorRequestDto && equalTo((UpdateMonitorRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateMonitorRequestDto other) { + return webhookIds.equals(other.webhookIds) + && limit.equals(other.limit) + && schedule.equals(other.schedule) + && timezone.equals(other.timezone); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.webhookIds, this.limit, this.schedule, this.timezone); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> webhookIds = Optional.empty(); + + private Optional limit = Optional.empty(); + + private Optional schedule = Optional.empty(); + + private Optional timezone = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateMonitorRequestDto other) { + webhookIds(other.getWebhookIds()); + limit(other.getLimit()); + schedule(other.getSchedule()); + timezone(other.getTimezone()); + return this; + } + + /** + *

Updated list of centralized webhook IDs for this event monitor.

+ *

Replaces all existing webhook assignments. Pass an empty array [] to clear all assignments. Omit to leave existing assignments unchanged.

+ */ + @JsonSetter(value = "webhook_ids", nulls = Nulls.SKIP) + public Builder webhookIds(Optional> webhookIds) { + this.webhookIds = webhookIds; + return this; + } + + public Builder webhookIds(List webhookIds) { + this.webhookIds = Optional.ofNullable(webhookIds); + return this; + } + + /** + *

Updated maximum number of records per event monitor run.

+ */ + @JsonSetter(value = "limit", nulls = Nulls.SKIP) + public Builder limit(Optional limit) { + this.limit = limit; + return this; + } + + public Builder limit(Integer limit) { + this.limit = Optional.ofNullable(limit); + return this; + } + + /** + *

New natural-language schedule that replaces the event monitor's current + * schedule. Examples: every day at 9 AM, every Monday at 6 PM EST.

+ *

Omit to keep the current schedule. The new schedule takes effect from the + * next scheduler reload, and the old schedule stops firing. Returns 422 if + * the text can't be parsed or runs would be spaced too closely.

+ */ + @JsonSetter(value = "schedule", nulls = Nulls.SKIP) + public Builder schedule(Optional schedule) { + this.schedule = schedule; + return this; + } + + public Builder schedule(String schedule) { + this.schedule = Optional.ofNullable(schedule); + return this; + } + + public Builder schedule(Nullable schedule) { + if (schedule.isNull()) { + this.schedule = null; + } else if (schedule.isEmpty()) { + this.schedule = Optional.empty(); + } else { + this.schedule = Optional.of(schedule.get()); + } + return this; + } + + /** + *

IANA timezone for the new schedule (for example, America/New_York). + * A timezone included in the schedule text takes precedence. Ignored if + * schedule is not set.

+ */ + @JsonSetter(value = "timezone", nulls = Nulls.SKIP) + public Builder timezone(Optional timezone) { + this.timezone = timezone; + return this; + } + + public Builder timezone(String timezone) { + this.timezone = Optional.ofNullable(timezone); + return this; + } + + public Builder timezone(Nullable timezone) { + if (timezone.isNull()) { + this.timezone = null; + } else if (timezone.isEmpty()) { + this.timezone = Optional.empty(); + } else { + this.timezone = Optional.of(timezone.get()); + } + return this; + } + + public UpdateMonitorRequestDto build() { + return new UpdateMonitorRequestDto(webhookIds, limit, schedule, timezone, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/DisableMonitorResponse.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/DisableMonitorResponse.java index 49ebeb4..89f3704 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/DisableMonitorResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.types; +package com.newscatcher.catchall.resources.eventmonitors.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -52,7 +52,7 @@ public String getMessage() { } /** - * @return ID of the disabled monitor. + * @return ID of the disabled event monitor. */ @JsonProperty("monitor_id") public String getMonitorId() { @@ -106,7 +106,7 @@ public interface MessageStage { public interface MonitorIdStage { /** - *

ID of the disabled monitor.

+ *

ID of the disabled event monitor.

*/ _FinalStage monitorId(@NotNull String monitorId); } @@ -163,7 +163,7 @@ public MonitorIdStage message(@NotNull String message) { } /** - *

ID of the disabled monitor.

+ *

ID of the disabled event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/EnableMonitorResponse.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/EnableMonitorResponse.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/types/EnableMonitorResponse.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/EnableMonitorResponse.java index 64b7630..03a133d 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/EnableMonitorResponse.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/EnableMonitorResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.types; +package com.newscatcher.catchall.resources.eventmonitors.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -52,7 +52,7 @@ public String getMessage() { } /** - * @return ID of the enabled monitor. + * @return ID of the enabled event monitor. */ @JsonProperty("monitor_id") public String getMonitorId() { @@ -106,7 +106,7 @@ public interface MessageStage { public interface MonitorIdStage { /** - *

ID of the enabled monitor.

+ *

ID of the enabled event monitor.

*/ _FinalStage monitorId(@NotNull String monitorId); } @@ -163,7 +163,7 @@ public MonitorIdStage message(@NotNull String message) { } /** - *

ID of the enabled monitor.

+ *

ID of the enabled event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsRequestSort.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsRequestSort.java similarity index 96% rename from src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsRequestSort.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsRequestSort.java index bf08dfd..5a64a32 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsRequestSort.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsRequestSort.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.types; +package com.newscatcher.catchall.resources.eventmonitors.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponse.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponse.java similarity index 91% rename from src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponse.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponse.java index 4f53dc5..f45e172 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponse.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.types; +package com.newscatcher.catchall.resources.eventmonitors.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -47,7 +47,7 @@ private ListMonitorJobsResponse( } /** - * @return Monitor identifier. + * @return Event monitor identifier. */ @JsonProperty("monitor_id") public String getMonitorId() { @@ -63,7 +63,7 @@ public ListMonitorJobsResponseSortOrder getSortOrder() { } /** - * @return Total number of jobs for this monitor. + * @return Total number of jobs for this event monitor. */ @JsonProperty("total_jobs") public int getTotalJobs() { @@ -71,7 +71,7 @@ public int getTotalJobs() { } /** - * @return Array of job executions for this monitor. + * @return Array of job executions for this event monitor. */ @JsonProperty("jobs") public List getJobs() { @@ -112,7 +112,7 @@ public static MonitorIdStage builder() { public interface MonitorIdStage { /** - *

Monitor identifier.

+ *

Event monitor identifier.

*/ SortOrderStage monitorId(@NotNull String monitorId); @@ -128,7 +128,7 @@ public interface SortOrderStage { public interface TotalJobsStage { /** - *

Total number of jobs for this monitor.

+ *

Total number of jobs for this event monitor.

*/ _FinalStage totalJobs(int totalJobs); } @@ -141,7 +141,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Array of job executions for this monitor.

+ *

Array of job executions for this event monitor.

*/ _FinalStage jobs(List jobs); @@ -175,7 +175,7 @@ public Builder from(ListMonitorJobsResponse other) { } /** - *

Monitor identifier.

+ *

Event monitor identifier.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -197,7 +197,7 @@ public TotalJobsStage sortOrder(@NotNull ListMonitorJobsResponseSortOrder sortOr } /** - *

Total number of jobs for this monitor.

+ *

Total number of jobs for this event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -208,7 +208,7 @@ public _FinalStage totalJobs(int totalJobs) { } /** - *

Array of job executions for this monitor.

+ *

Array of job executions for this event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -220,7 +220,7 @@ public _FinalStage addAllJobs(List jobs) { } /** - *

Array of job executions for this monitor.

+ *

Array of job executions for this event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -230,7 +230,7 @@ public _FinalStage addJobs(MonitorJobItem jobs) { } /** - *

Array of job executions for this monitor.

+ *

Array of job executions for this event monitor.

*/ @java.lang.Override @JsonSetter(value = "jobs", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponseSortOrder.java b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponseSortOrder.java similarity index 97% rename from src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponseSortOrder.java rename to src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponseSortOrder.java index eb62882..1ae54ff 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/ListMonitorJobsResponseSortOrder.java +++ b/src/main/java/com/newscatcher/catchall/resources/eventmonitors/types/ListMonitorJobsResponseSortOrder.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.catchall.resources.monitors.types; +package com.newscatcher.catchall.resources.eventmonitors.types; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java index 9174b48..cbab211 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java @@ -12,11 +12,13 @@ import com.newscatcher.catchall.resources.jobs.requests.GetJobStatusRequest; import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; +import com.newscatcher.catchall.resources.jobs.requests.ListSourceGroupsRequest; import com.newscatcher.catchall.resources.jobs.requests.SubmitRequestDto; import com.newscatcher.catchall.resources.jobs.requests.ValidateQueryRequestDto; import com.newscatcher.catchall.types.ContinueResponseDto; import com.newscatcher.catchall.types.DeleteJobResponseDto; import com.newscatcher.catchall.types.InitializeResponseDto; +import com.newscatcher.catchall.types.ListSourceGroupsResponseDto; import com.newscatcher.catchall.types.ListUserJobsResponseDto; import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; @@ -258,4 +260,57 @@ public CompletableFuture deleteJob( String jobId, DeleteJobRequest request, RequestOptions requestOptions) { return this.rawClient.deleteJob(jobId, request, requestOptions).thenApply(response -> response.body()); } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture listSourceGroups() { + return this.rawClient.listSourceGroups().thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture listSourceGroups(RequestOptions requestOptions) { + return this.rawClient.listSourceGroups(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture listSourceGroups(ListSourceGroupsRequest request) { + return this.rawClient.listSourceGroups(request).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture listSourceGroups( + ListSourceGroupsRequest request, RequestOptions requestOptions) { + return this.rawClient.listSourceGroups(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java index 562ea4e..7683293 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java @@ -25,12 +25,14 @@ import com.newscatcher.catchall.resources.jobs.requests.GetJobStatusRequest; import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; +import com.newscatcher.catchall.resources.jobs.requests.ListSourceGroupsRequest; import com.newscatcher.catchall.resources.jobs.requests.SubmitRequestDto; import com.newscatcher.catchall.resources.jobs.requests.ValidateQueryRequestDto; import com.newscatcher.catchall.types.ContinueResponseDto; import com.newscatcher.catchall.types.DeleteJobResponseDto; import com.newscatcher.catchall.types.Error; import com.newscatcher.catchall.types.InitializeResponseDto; +import com.newscatcher.catchall.types.ListSourceGroupsResponseDto; import com.newscatcher.catchall.types.ListUserJobsResponseDto; import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; @@ -148,10 +150,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 @@ -240,6 +249,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), @@ -336,6 +350,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), @@ -437,6 +456,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), @@ -542,6 +566,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), @@ -654,6 +683,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), @@ -761,6 +795,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), @@ -861,6 +900,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), @@ -1007,4 +1051,141 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); return future; } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture> listSourceGroups() { + return listSourceGroups(ListSourceGroupsRequest.builder().build()); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture> listSourceGroups( + RequestOptions requestOptions) { + return listSourceGroups(ListSourceGroupsRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture> listSourceGroups( + ListSourceGroupsRequest request) { + return listSourceGroups(request, null); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CompletableFuture> listSourceGroups( + ListSourceGroupsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/source-groups"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new CatchAllApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, ListSourceGroupsResponseDto.class), + response)); + return; + } + try { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (JsonProcessingException e) { + future.completeExceptionally( + new CatchAllApiException("Failed to deserialize response: " + e.getMessage(), e)); + } catch (IOException e) { + future.completeExceptionally(new CatchAllApiException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new CatchAllApiException("Network error executing HTTP request", e)); + } + }); + return future; + } } diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java b/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java index 9360421..f55a16b 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java @@ -12,11 +12,13 @@ import com.newscatcher.catchall.resources.jobs.requests.GetJobStatusRequest; import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; +import com.newscatcher.catchall.resources.jobs.requests.ListSourceGroupsRequest; import com.newscatcher.catchall.resources.jobs.requests.SubmitRequestDto; import com.newscatcher.catchall.resources.jobs.requests.ValidateQueryRequestDto; import com.newscatcher.catchall.types.ContinueResponseDto; import com.newscatcher.catchall.types.DeleteJobResponseDto; import com.newscatcher.catchall.types.InitializeResponseDto; +import com.newscatcher.catchall.types.ListSourceGroupsResponseDto; import com.newscatcher.catchall.types.ListUserJobsResponseDto; import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; @@ -249,4 +251,57 @@ public DeleteJobResponseDto deleteJob(String jobId, DeleteJobRequest request) { public DeleteJobResponseDto deleteJob(String jobId, DeleteJobRequest request, RequestOptions requestOptions) { return this.rawClient.deleteJob(jobId, request, requestOptions).body(); } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public ListSourceGroupsResponseDto listSourceGroups() { + return this.rawClient.listSourceGroups().body(); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public ListSourceGroupsResponseDto listSourceGroups(RequestOptions requestOptions) { + return this.rawClient.listSourceGroups(requestOptions).body(); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public ListSourceGroupsResponseDto listSourceGroups(ListSourceGroupsRequest request) { + return this.rawClient.listSourceGroups(request).body(); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public ListSourceGroupsResponseDto listSourceGroups( + ListSourceGroupsRequest request, RequestOptions requestOptions) { + return this.rawClient.listSourceGroups(request, requestOptions).body(); + } } diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java b/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java index 917c15f..fae0440 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java @@ -25,12 +25,14 @@ import com.newscatcher.catchall.resources.jobs.requests.GetJobStatusRequest; import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; +import com.newscatcher.catchall.resources.jobs.requests.ListSourceGroupsRequest; import com.newscatcher.catchall.resources.jobs.requests.SubmitRequestDto; import com.newscatcher.catchall.resources.jobs.requests.ValidateQueryRequestDto; import com.newscatcher.catchall.types.ContinueResponseDto; import com.newscatcher.catchall.types.DeleteJobResponseDto; import com.newscatcher.catchall.types.Error; import com.newscatcher.catchall.types.InitializeResponseDto; +import com.newscatcher.catchall.types.ListSourceGroupsResponseDto; import com.newscatcher.catchall.types.ListUserJobsResponseDto; import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; @@ -139,9 +141,13 @@ public CatchAllApiHttpResponse getUserJobs( 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 @@ -215,6 +221,9 @@ public CatchAllApiHttpResponse validateQuery( } 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); @@ -292,6 +301,9 @@ public CatchAllApiHttpResponse initialize( } 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); @@ -372,6 +384,9 @@ public CatchAllApiHttpResponse createJob( 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); @@ -456,6 +471,9 @@ public CatchAllApiHttpResponse getJobStatus( } 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); @@ -547,6 +565,9 @@ public CatchAllApiHttpResponse getJobResults( } 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); @@ -634,6 +655,9 @@ public CatchAllApiHttpResponse getJobResultsCsv( } 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); @@ -713,6 +737,9 @@ public CatchAllApiHttpResponse continueJob( 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); @@ -824,4 +851,120 @@ public CatchAllApiHttpResponse deleteJob( throw new CatchAllApiException("Network error executing HTTP request", e); } } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CatchAllApiHttpResponse listSourceGroups() { + return listSourceGroups(ListSourceGroupsRequest.builder().build()); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CatchAllApiHttpResponse listSourceGroups(RequestOptions requestOptions) { + return listSourceGroups(ListSourceGroupsRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CatchAllApiHttpResponse listSourceGroups(ListSourceGroupsRequest request) { + return listSourceGroups(request, null); + } + + /** + * Returns a paginated list of source groups visible to your organization. + *

A source group is a named, curated domain allowlist maintained by NewsCatcher — for + * example "Top 100 US Finance". Pass a group's slug in source_groups when creating + * a job to scope article fetching to that group's domains, instead of maintaining a + * long domain list yourself.

+ *

The response covers public groups plus any restricted groups your organization has + * been granted access to. Each entry returns slug, name, and description.

+ */ + public CatchAllApiHttpResponse listSourceGroups( + ListSourceGroupsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/source-groups"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) { + okhttpRequest = okhttpRequest + .newBuilder() + .tag( + RetryInterceptor.MaxRetriesOverride.class, + new RetryInterceptor.MaxRetriesOverride( + requestOptions.getMaxRetries().get())) + .build(); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new CatchAllApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListSourceGroupsResponseDto.class), + response); + } + try { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to deserialize response: " + e.getMessage(), e); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } } diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ListSourceGroupsRequest.java b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ListSourceGroupsRequest.java new file mode 100644 index 0000000..8e9b923 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ListSourceGroupsRequest.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.jobs.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListSourceGroupsRequest.Builder.class) +public final class ListSourceGroupsRequest { + private final Optional page; + + private final Optional pageSize; + + private final Map additionalProperties; + + private ListSourceGroupsRequest( + Optional page, Optional pageSize, Map additionalProperties) { + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of source groups per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSourceGroupsRequest && equalTo((ListSourceGroupsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSourceGroupsRequest other) { + return page.equals(other.page) && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional page = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListSourceGroupsRequest other) { + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + /** + *

Page number to retrieve.

+ */ + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + /** + *

Number of source groups per page.

+ */ + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public ListSourceGroupsRequest build() { + return new ListSourceGroupsRequest(page, pageSize, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/SubmitRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/SubmitRequestDto.java index 4620559..aaa80e3 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/SubmitRequestDto.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/SubmitRequestDto.java @@ -55,6 +55,8 @@ public final class SubmitRequestDto { private final Optional edAssociationType; + private final Optional> sourceGroups; + private final Map additionalProperties; private SubmitRequestDto( @@ -72,6 +74,7 @@ private SubmitRequestDto( Optional> webhookIds, Optional fetchAllWatchlistNews, Optional edAssociationType, + Optional> sourceGroups, Map additionalProperties) { this.query = query; this.context = context; @@ -87,6 +90,7 @@ private SubmitRequestDto( this.webhookIds = webhookIds; this.fetchAllWatchlistNews = fetchAllWatchlistNews; this.edAssociationType = edAssociationType; + this.sourceGroups = sourceGroups; this.additionalProperties = additionalProperties; } @@ -150,7 +154,7 @@ public Optional getMode() { } /** - * @return Dataset IDs to connect to the job. When provided, this enables Company Watchlist mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min. + * @return Dataset IDs to connect to the job. When provided, this enables Company Monitors mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min. *

The dataset must have latest_status: ready before the job is submitted. Submitting with a non-existent or inaccessible dataset ID returns 400.

*/ @JsonProperty("connected_dataset_ids") @@ -184,7 +188,7 @@ public Optional> getWebhookIds() { } /** - * @return When true, retrieves all news for connected Company Watchlist entities + * @return When true, retrieves all news for connected Company Monitors entities * without topic filtering. Requires connected_dataset_ids to be set. */ @JsonProperty("fetch_all_watchlist_news") @@ -203,6 +207,16 @@ public Optional getEdAssociationType() { return edAssociationType; } + /** + * @return Slugs of source groups to scope fetching to their curated domain allowlists. + *

Source groups are named domain lists maintained by NewsCatcher (for example "Top 100 US Finance"). Retrieve the groups available to your organization with List source groups.

+ *

Domains are resolved when the job runs, so a group's current membership always applies. Maximum 20 groups per job. An unknown or inaccessible slug is rejected at submit time.

+ */ + @JsonProperty("source_groups") + public Optional> getSourceGroups() { + return sourceGroups; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -228,7 +242,8 @@ private boolean equalTo(SubmitRequestDto other) { && projectId.equals(other.projectId) && webhookIds.equals(other.webhookIds) && fetchAllWatchlistNews.equals(other.fetchAllWatchlistNews) - && edAssociationType.equals(other.edAssociationType); + && edAssociationType.equals(other.edAssociationType) + && sourceGroups.equals(other.sourceGroups); } @java.lang.Override @@ -247,7 +262,8 @@ public int hashCode() { this.projectId, this.webhookIds, this.fetchAllWatchlistNews, - this.edAssociationType); + this.edAssociationType, + this.sourceGroups); } @java.lang.Override @@ -320,7 +336,7 @@ public interface _FinalStage { _FinalStage mode(SubmitRequestDtoMode mode); /** - *

Dataset IDs to connect to the job. When provided, this enables Company Watchlist mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

+ *

Dataset IDs to connect to the job. When provided, this enables Company Monitors mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

*

The dataset must have latest_status: ready before the job is submitted. Submitting with a non-existent or inaccessible dataset ID returns 400.

*/ _FinalStage connectedDatasetIds(Optional> connectedDatasetIds); @@ -350,7 +366,7 @@ public interface _FinalStage { _FinalStage webhookIds(List webhookIds); /** - *

When true, retrieves all news for connected Company Watchlist entities + *

When true, retrieves all news for connected Company Monitors entities * without topic filtering. Requires connected_dataset_ids to be set.

*/ _FinalStage fetchAllWatchlistNews(Optional fetchAllWatchlistNews); @@ -366,12 +382,23 @@ public interface _FinalStage { _FinalStage edAssociationType(Optional edAssociationType); _FinalStage edAssociationType(EntityAssociationType edAssociationType); + + /** + *

Slugs of source groups to scope fetching to their curated domain allowlists.

+ *

Source groups are named domain lists maintained by NewsCatcher (for example "Top 100 US Finance"). Retrieve the groups available to your organization with List source groups.

+ *

Domains are resolved when the job runs, so a group's current membership always applies. Maximum 20 groups per job. An unknown or inaccessible slug is rejected at submit time.

+ */ + _FinalStage sourceGroups(Optional> sourceGroups); + + _FinalStage sourceGroups(List sourceGroups); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements QueryStage, _FinalStage { private String query; + private Optional> sourceGroups = Optional.empty(); + private Optional edAssociationType = Optional.empty(); private Optional fetchAllWatchlistNews = Optional.empty(); @@ -419,6 +446,7 @@ public Builder from(SubmitRequestDto other) { webhookIds(other.getWebhookIds()); fetchAllWatchlistNews(other.getFetchAllWatchlistNews()); edAssociationType(other.getEdAssociationType()); + sourceGroups(other.getSourceGroups()); return this; } @@ -429,6 +457,30 @@ public _FinalStage query(@NotNull String query) { return this; } + /** + *

Slugs of source groups to scope fetching to their curated domain allowlists.

+ *

Source groups are named domain lists maintained by NewsCatcher (for example "Top 100 US Finance"). Retrieve the groups available to your organization with List source groups.

+ *

Domains are resolved when the job runs, so a group's current membership always applies. Maximum 20 groups per job. An unknown or inaccessible slug is rejected at submit time.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sourceGroups(List sourceGroups) { + this.sourceGroups = Optional.ofNullable(sourceGroups); + return this; + } + + /** + *

Slugs of source groups to scope fetching to their curated domain allowlists.

+ *

Source groups are named domain lists maintained by NewsCatcher (for example "Top 100 US Finance"). Retrieve the groups available to your organization with List source groups.

+ *

Domains are resolved when the job runs, so a group's current membership always applies. Maximum 20 groups per job. An unknown or inaccessible slug is rejected at submit time.

+ */ + @java.lang.Override + @JsonSetter(value = "source_groups", nulls = Nulls.SKIP) + public _FinalStage sourceGroups(Optional> sourceGroups) { + this.sourceGroups = sourceGroups; + return this; + } + /** *

Filter events by entity association type. event_associated keeps only * events where the entity is a direct actor. mention keeps only events @@ -456,7 +508,7 @@ public _FinalStage edAssociationType(Optional edAssociati } /** - *

When true, retrieves all news for connected Company Watchlist entities + *

When true, retrieves all news for connected Company Monitors entities * without topic filtering. Requires connected_dataset_ids to be set.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -467,7 +519,7 @@ public _FinalStage fetchAllWatchlistNews(Boolean fetchAllWatchlistNews) { } /** - *

When true, retrieves all news for connected Company Watchlist entities + *

When true, retrieves all news for connected Company Monitors entities * without topic filtering. Requires connected_dataset_ids to be set.

*/ @java.lang.Override @@ -540,7 +592,7 @@ public _FinalStage edScoreMin(Optional edScoreMin) { } /** - *

Dataset IDs to connect to the job. When provided, this enables Company Watchlist mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

+ *

Dataset IDs to connect to the job. When provided, this enables Company Monitors mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

*

The dataset must have latest_status: ready before the job is submitted. Submitting with a non-existent or inaccessible dataset ID returns 400.

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -551,7 +603,7 @@ public _FinalStage connectedDatasetIds(List connectedDatasetIds) { } /** - *

Dataset IDs to connect to the job. When provided, this enables Company Watchlist mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

+ *

Dataset IDs to connect to the job. When provided, this enables Company Monitors mode — the job returns only events relevant to companies in the connected datasets. To set the minimum relevance threshold, use ed_score_min.

*

The dataset must have latest_status: ready before the job is submitted. Submitting with a non-existent or inaccessible dataset ID returns 400.

*/ @java.lang.Override @@ -710,6 +762,7 @@ public SubmitRequestDto build() { webhookIds, fetchAllWatchlistNews, edAssociationType, + sourceGroups, additionalProperties); } diff --git a/src/main/java/com/newscatcher/catchall/resources/meta/AsyncRawMetaClient.java b/src/main/java/com/newscatcher/catchall/resources/meta/AsyncRawMetaClient.java index 4502cdd..661d0f3 100644 --- a/src/main/java/com/newscatcher/catchall/resources/meta/AsyncRawMetaClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/meta/AsyncRawMetaClient.java @@ -12,6 +12,7 @@ import com.newscatcher.catchall.core.RequestOptions; import com.newscatcher.catchall.core.RetryInterceptor; import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.UnauthorizedError; import com.newscatcher.catchall.resources.meta.types.GetVersionResponse; import com.newscatcher.catchall.resources.meta.types.HealthCheckResponse; import com.newscatcher.catchall.types.Error; @@ -228,10 +229,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 diff --git a/src/main/java/com/newscatcher/catchall/resources/meta/RawMetaClient.java b/src/main/java/com/newscatcher/catchall/resources/meta/RawMetaClient.java index 122d044..715c321 100644 --- a/src/main/java/com/newscatcher/catchall/resources/meta/RawMetaClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/meta/RawMetaClient.java @@ -12,6 +12,7 @@ import com.newscatcher.catchall.core.RequestOptions; import com.newscatcher.catchall.core.RetryInterceptor; import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.UnauthorizedError; import com.newscatcher.catchall.resources.meta.types.GetVersionResponse; import com.newscatcher.catchall.resources.meta.types.HealthCheckResponse; import com.newscatcher.catchall.types.Error; @@ -189,9 +190,13 @@ public CatchAllApiHttpResponse getPlanLimits(RequestOp 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 diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/UpdateMonitorRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/UpdateMonitorRequestDto.java deleted file mode 100644 index 9330a43..0000000 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/UpdateMonitorRequestDto.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.catchall.resources.monitors.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.catchall.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = UpdateMonitorRequestDto.Builder.class) -public final class UpdateMonitorRequestDto { - private final Optional> webhookIds; - - private final Optional limit; - - private final Map additionalProperties; - - private UpdateMonitorRequestDto( - Optional> webhookIds, Optional limit, Map additionalProperties) { - this.webhookIds = webhookIds; - this.limit = limit; - this.additionalProperties = additionalProperties; - } - - /** - * @return Updated list of centralized webhook IDs for this monitor. - *

Replaces all existing webhook assignments. Pass an empty array [] to clear all assignments. Omit to leave existing assignments unchanged.

- */ - @JsonProperty("webhook_ids") - public Optional> getWebhookIds() { - return webhookIds; - } - - /** - * @return Updated maximum number of records per monitor run. - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpdateMonitorRequestDto && equalTo((UpdateMonitorRequestDto) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UpdateMonitorRequestDto other) { - return webhookIds.equals(other.webhookIds) && limit.equals(other.limit); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.webhookIds, this.limit); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> webhookIds = Optional.empty(); - - private Optional limit = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UpdateMonitorRequestDto other) { - webhookIds(other.getWebhookIds()); - limit(other.getLimit()); - return this; - } - - /** - *

Updated list of centralized webhook IDs for this monitor.

- *

Replaces all existing webhook assignments. Pass an empty array [] to clear all assignments. Omit to leave existing assignments unchanged.

- */ - @JsonSetter(value = "webhook_ids", nulls = Nulls.SKIP) - public Builder webhookIds(Optional> webhookIds) { - this.webhookIds = webhookIds; - return this; - } - - public Builder webhookIds(List webhookIds) { - this.webhookIds = Optional.ofNullable(webhookIds); - return this; - } - - /** - *

Updated maximum number of records per monitor run.

- */ - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.ofNullable(limit); - return this; - } - - public UpdateMonitorRequestDto build() { - return new UpdateMonitorRequestDto(webhookIds, limit, additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java index 85c6658..29542f1 100644 --- a/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java @@ -16,6 +16,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.projects.requests.AddResourceRequestDto; import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; @@ -142,6 +143,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), @@ -239,6 +245,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), @@ -344,6 +355,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), @@ -454,6 +470,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), @@ -566,6 +587,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), @@ -682,6 +708,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), @@ -803,6 +834,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), @@ -912,6 +948,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), @@ -1041,6 +1082,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/projects/RawProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java index 9e33c3d..d1454f3 100644 --- a/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java @@ -16,6 +16,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.projects.requests.AddResourceRequestDto; import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; @@ -132,6 +133,9 @@ public CatchAllApiHttpResponse listProjects( } 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); @@ -210,6 +214,9 @@ public CatchAllApiHttpResponse createProject( } 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); @@ -294,6 +301,9 @@ public CatchAllApiHttpResponse getProject( } 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 +394,9 @@ public CatchAllApiHttpResponse deleteProject( 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); @@ -478,6 +491,9 @@ public CatchAllApiHttpResponse updateProject( } 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); @@ -573,6 +589,9 @@ public CatchAllApiHttpResponse getProjectOverview( } 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); @@ -674,6 +693,9 @@ public CatchAllApiHttpResponse listProjectResour } 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); @@ -761,6 +783,9 @@ public CatchAllApiHttpResponse addResourceToProject( 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); @@ -871,6 +896,9 @@ public CatchAllApiHttpResponse removeResourceFromProj } 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/projects/requests/DeleteProjectRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java index 8552907..6130053 100644 --- a/src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java @@ -30,7 +30,7 @@ private DeleteProjectRequest(Optional deleteResources, MapWebhooks are never deleted by either setting — they are only detached from the project.

*/ @JsonProperty("delete_resources") @@ -82,7 +82,7 @@ public Builder from(DeleteProjectRequest other) { } /** - *

If true, permanently deletes all resources (jobs, monitors, datasets, monitor groups) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted.

+ *

If true, permanently deletes all resources (jobs, event monitors, datasets, event monitor groups) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted.

*

Webhooks are never deleted by either setting — they are only detached from the project.

*/ @JsonSetter(value = "delete_resources", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java index 1be0954..589f6c0 100644 --- a/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java @@ -16,6 +16,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.webhooks.requests.AssignWebhookResourceRequestDto; import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; @@ -103,6 +104,10 @@ public CompletableFuture> listW QueryStringMapper.addQueryParameter( httpUrl, "search", request.getSearch().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,11 +146,21 @@ 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), 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( @@ -240,6 +255,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), @@ -350,6 +370,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), @@ -392,7 +417,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture> deleteWebhook(String webhookId) { return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build()); @@ -400,7 +425,7 @@ public CompletableFuture> deleteWebhook(String web /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture> deleteWebhook( String webhookId, RequestOptions requestOptions) { @@ -409,7 +434,7 @@ public CompletableFuture> deleteWebhook( /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture> deleteWebhook( String webhookId, DeleteWebhookRequest request) { @@ -418,7 +443,7 @@ public CompletableFuture> deleteWebhook( /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture> deleteWebhook( String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { @@ -462,6 +487,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), @@ -574,6 +604,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), @@ -616,7 +651,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture> testWebhook(String webhookId) { return testWebhook(webhookId, TestWebhookRequestDto.builder().build()); @@ -624,7 +659,7 @@ public CompletableFuture> testWe /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture> testWebhook( String webhookId, RequestOptions requestOptions) { @@ -633,7 +668,7 @@ public CompletableFuture> testWe /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture> testWebhook( String webhookId, TestWebhookRequestDto request) { @@ -642,7 +677,7 @@ public CompletableFuture> testWe /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture> testWebhook( String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { @@ -697,6 +732,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), @@ -824,6 +864,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), @@ -865,7 +910,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -876,7 +921,7 @@ public CompletableFutureA single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -940,6 +985,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), @@ -1072,6 +1122,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), @@ -1201,6 +1256,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), @@ -1243,7 +1303,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -1255,7 +1315,7 @@ public CompletableFuture> triggerWebhook( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -1311,6 +1371,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), @@ -1418,6 +1483,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/webhooks/AsyncWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java index 4dca806..715a0e1 100644 --- a/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java @@ -122,7 +122,7 @@ public CompletableFuture getWebhook( /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture deleteWebhook(String webhookId) { return this.rawClient.deleteWebhook(webhookId).thenApply(response -> response.body()); @@ -130,7 +130,7 @@ public CompletableFuture deleteWebhook(String webhookId) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture deleteWebhook(String webhookId, RequestOptions requestOptions) { return this.rawClient.deleteWebhook(webhookId, requestOptions).thenApply(response -> response.body()); @@ -138,7 +138,7 @@ public CompletableFuture deleteWebhook(String webhookId, RequestOptions re /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture deleteWebhook(String webhookId, DeleteWebhookRequest request) { return this.rawClient.deleteWebhook(webhookId, request).thenApply(response -> response.body()); @@ -146,7 +146,7 @@ public CompletableFuture deleteWebhook(String webhookId, DeleteWebhookRequ /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CompletableFuture deleteWebhook( String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { @@ -185,7 +185,7 @@ public CompletableFuture updateWebhook( /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture testWebhook(String webhookId) { return this.rawClient.testWebhook(webhookId).thenApply(response -> response.body()); @@ -193,7 +193,7 @@ public CompletableFuture testWebhook(String webhookId) { /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture testWebhook(String webhookId, RequestOptions requestOptions) { return this.rawClient.testWebhook(webhookId, requestOptions).thenApply(response -> response.body()); @@ -201,7 +201,7 @@ public CompletableFuture testWebhook(String webhookId, R /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture testWebhook(String webhookId, TestWebhookRequestDto request) { return this.rawClient.testWebhook(webhookId, request).thenApply(response -> response.body()); @@ -209,7 +209,7 @@ public CompletableFuture testWebhook(String webhookId, T /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CompletableFuture testWebhook( String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { @@ -250,7 +250,7 @@ public CompletableFuture listWebhookResources( } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -261,7 +261,7 @@ public CompletableFuture assignWebhookResource } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -367,7 +367,7 @@ public CompletableFuture listWebhooksForResource( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -379,7 +379,7 @@ public CompletableFuture triggerWebhook( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java index 0d8b6ee..eff2608 100644 --- a/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java @@ -16,6 +16,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.webhooks.requests.AssignWebhookResourceRequestDto; import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; @@ -97,6 +98,10 @@ public CatchAllApiHttpResponse listWebhooks( QueryStringMapper.addQueryParameter( httpUrl, "search", request.getSearch().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); @@ -131,9 +136,15 @@ public CatchAllApiHttpResponse listWebhooks( } 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); + 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), @@ -211,6 +222,9 @@ public CatchAllApiHttpResponse createWebhook( } 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); @@ -298,6 +312,9 @@ public CatchAllApiHttpResponse getWebhook( } 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); @@ -324,7 +341,7 @@ public CatchAllApiHttpResponse getWebhook( /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CatchAllApiHttpResponse deleteWebhook(String webhookId) { return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build()); @@ -332,7 +349,7 @@ public CatchAllApiHttpResponse deleteWebhook(String webhookId) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CatchAllApiHttpResponse deleteWebhook(String webhookId, RequestOptions requestOptions) { return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build(), requestOptions); @@ -340,7 +357,7 @@ public CatchAllApiHttpResponse deleteWebhook(String webhookId, RequestOpti /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CatchAllApiHttpResponse deleteWebhook(String webhookId, DeleteWebhookRequest request) { return deleteWebhook(webhookId, request, null); @@ -348,7 +365,7 @@ public CatchAllApiHttpResponse deleteWebhook(String webhookId, DeleteWebho /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public CatchAllApiHttpResponse deleteWebhook( String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { @@ -388,6 +405,9 @@ public CatchAllApiHttpResponse deleteWebhook( 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); @@ -482,6 +502,9 @@ public CatchAllApiHttpResponse updateWebhook( } 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); @@ -508,7 +531,7 @@ public CatchAllApiHttpResponse updateWebhook( /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CatchAllApiHttpResponse testWebhook(String webhookId) { return testWebhook(webhookId, TestWebhookRequestDto.builder().build()); @@ -516,7 +539,7 @@ public CatchAllApiHttpResponse testWebhook(String webhoo /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CatchAllApiHttpResponse testWebhook( String webhookId, RequestOptions requestOptions) { @@ -525,7 +548,7 @@ public CatchAllApiHttpResponse testWebhook( /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CatchAllApiHttpResponse testWebhook( String webhookId, TestWebhookRequestDto request) { @@ -534,7 +557,7 @@ public CatchAllApiHttpResponse testWebhook( /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public CatchAllApiHttpResponse testWebhook( String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { @@ -585,6 +608,9 @@ public CatchAllApiHttpResponse testWebhook( } 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); @@ -690,6 +716,9 @@ public CatchAllApiHttpResponse listWebhookResou } 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); @@ -715,7 +744,7 @@ public CatchAllApiHttpResponse listWebhookResou } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -726,7 +755,7 @@ public CatchAllApiHttpResponse assignWebhookRe } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -783,6 +812,9 @@ public CatchAllApiHttpResponse assignWebhookRe 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); @@ -895,6 +927,9 @@ public CatchAllApiHttpResponse removeWebhookResource( 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); @@ -1006,6 +1041,9 @@ public CatchAllApiHttpResponse listWebhooksForResource( } 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); @@ -1032,7 +1070,7 @@ public CatchAllApiHttpResponse listWebhooksForResource( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -1044,7 +1082,7 @@ public CatchAllApiHttpResponse triggerWebhook( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -1096,6 +1134,9 @@ public CatchAllApiHttpResponse triggerWebhook( 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); @@ -1182,6 +1223,9 @@ public CatchAllApiHttpResponse getWebhookDeliveryHis } 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/webhooks/WebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java index a21eda0..a341496 100644 --- a/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java @@ -119,7 +119,7 @@ public GetWebhookResponseDto getWebhook( /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public void deleteWebhook(String webhookId) { this.rawClient.deleteWebhook(webhookId).body(); @@ -127,7 +127,7 @@ public void deleteWebhook(String webhookId) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public void deleteWebhook(String webhookId, RequestOptions requestOptions) { this.rawClient.deleteWebhook(webhookId, requestOptions).body(); @@ -135,7 +135,7 @@ public void deleteWebhook(String webhookId, RequestOptions requestOptions) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public void deleteWebhook(String webhookId, DeleteWebhookRequest request) { this.rawClient.deleteWebhook(webhookId, request).body(); @@ -143,7 +143,7 @@ public void deleteWebhook(String webhookId, DeleteWebhookRequest request) { /** * Permanently deletes a webhook and removes all resource assignments. - *

Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.

+ *

Assigned jobs and event monitors no longer trigger delivery to this webhook. This operation cannot be undone.

*/ public void deleteWebhook(String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { this.rawClient.deleteWebhook(webhookId, request, requestOptions).body(); @@ -180,7 +180,7 @@ public UpdateWebhookResponseDto updateWebhook( /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public TestWebhookResponseDto testWebhook(String webhookId) { return this.rawClient.testWebhook(webhookId).body(); @@ -188,7 +188,7 @@ public TestWebhookResponseDto testWebhook(String webhookId) { /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public TestWebhookResponseDto testWebhook(String webhookId, RequestOptions requestOptions) { return this.rawClient.testWebhook(webhookId, requestOptions).body(); @@ -196,7 +196,7 @@ public TestWebhookResponseDto testWebhook(String webhookId, RequestOptions reque /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public TestWebhookResponseDto testWebhook(String webhookId, TestWebhookRequestDto request) { return this.rawClient.testWebhook(webhookId, request).body(); @@ -204,7 +204,7 @@ public TestWebhookResponseDto testWebhook(String webhookId, TestWebhookRequestDt /** * Sends a test HTTP request to the webhook URL using the webhook's configured method, headers, and auth. Returns the response from the target endpoint. - *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or monitor.

+ *

Use this to verify URL reachability and authentication before attaching the webhook to a live job or event monitor.

*/ public TestWebhookResponseDto testWebhook( String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { @@ -243,7 +243,7 @@ public ListWebhookResourcesResponseDto listWebhookResources( } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -254,7 +254,7 @@ public AssignWebhookResourceResponseDto assignWebhookResource( } /** - * Attaches a job, monitor, or monitor group to the webhook. When the + * Attaches a job, event monitor, or event monitor group to the webhook. When the * resource completes, the webhook receives a delivery. *

A single webhook can be assigned to multiple resources. Each resource * can have up to 5 webhooks assigned.

@@ -358,7 +358,7 @@ public ListWebhooksResponseDto listWebhooksForResource( /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

@@ -369,7 +369,7 @@ public void triggerWebhook(MappableResourceType resourceType, String resourceId, /** * Manually dispatches a webhook delivery for a resource on demand, without - * waiting for the next job or monitor cycle. + * waiting for the next job or event monitor cycle. *

Use this to re-deliver results after a failed delivery, replay a specific * job's results, or validate a webhook against live data. The webhook must * already be assigned to the resource.

diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java index d5efc70..f40bd1f 100644 --- a/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java @@ -26,16 +26,20 @@ public final class ListWebhooksRequest { private final Optional search; + private final Optional projectId; + private final Map additionalProperties; private ListWebhooksRequest( Optional page, Optional pageSize, Optional search, + Optional projectId, Map additionalProperties) { this.page = page; this.pageSize = pageSize; this.search = search; + this.projectId = projectId; this.additionalProperties = additionalProperties; } @@ -63,6 +67,14 @@ public Optional getSearch() { return search; } + /** + * @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; @@ -75,12 +87,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListWebhooksRequest other) { - return page.equals(other.page) && pageSize.equals(other.pageSize) && search.equals(other.search); + return page.equals(other.page) + && pageSize.equals(other.pageSize) + && search.equals(other.search) + && projectId.equals(other.projectId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.page, this.pageSize, this.search); + return Objects.hash(this.page, this.pageSize, this.search, this.projectId); } @java.lang.Override @@ -100,6 +115,8 @@ public static final class Builder { private Optional search = Optional.empty(); + private Optional projectId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -109,6 +126,7 @@ public Builder from(ListWebhooksRequest other) { page(other.getPage()); pageSize(other.getPageSize()); search(other.getSearch()); + projectId(other.getProjectId()); return this; } @@ -154,8 +172,22 @@ public Builder search(String search) { 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 ListWebhooksRequest build() { - return new ListWebhooksRequest(page, pageSize, search, additionalProperties); + return new ListWebhooksRequest(page, pageSize, search, projectId, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/newscatcher/catchall/types/BaseRecord.java b/src/main/java/com/newscatcher/catchall/types/BaseRecord.java index 524126f..c5c3515 100644 --- a/src/main/java/com/newscatcher/catchall/types/BaseRecord.java +++ b/src/main/java/com/newscatcher/catchall/types/BaseRecord.java @@ -59,7 +59,7 @@ public String getRecordTitle() { /** * @return Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content. *

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

*/ @JsonProperty("enrichment") public BaseRecordEnrichment getEnrichment() { @@ -117,7 +117,7 @@ public interface EnrichmentStage { /** *

Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

*

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

*/ _FinalStage enrichment(@NotNull BaseRecordEnrichment enrichment); } @@ -176,7 +176,7 @@ public EnrichmentStage recordTitle(@NotNull String recordTitle) { /** *

Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

*

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/types/CreateEntityRequest.java b/src/main/java/com/newscatcher/catchall/types/CreateEntityRequest.java index 5228c28..0264d6b 100644 --- a/src/main/java/com/newscatcher/catchall/types/CreateEntityRequest.java +++ b/src/main/java/com/newscatcher/catchall/types/CreateEntityRequest.java @@ -62,7 +62,7 @@ public Optional getEntityType() { } /** - * @return Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality. + * @return Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality. */ @JsonProperty("description") public Optional getDescription() { @@ -137,7 +137,7 @@ public interface _FinalStage { _FinalStage entityType(EntityType entityType); /** - *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

+ *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

*/ _FinalStage description(Optional description); @@ -227,7 +227,7 @@ public _FinalStage externalEntityId(Optional externalEntityId) { } /** - *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

+ *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -237,7 +237,7 @@ public _FinalStage description(String description) { } /** - *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

+ *

Free-text description of the entity used for disambiguation when similar names exist. See Writing effective descriptions for guidance on improving matching quality.

*/ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/CreateMonitorResponseDto.java b/src/main/java/com/newscatcher/catchall/types/CreateMonitorResponseDto.java index 4626eb1..7b1129b 100644 --- a/src/main/java/com/newscatcher/catchall/types/CreateMonitorResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/CreateMonitorResponseDto.java @@ -38,7 +38,7 @@ private CreateMonitorResponseDto( } /** - * @return Monitor ID if successful, null if error. + * @return Event monitor ID if successful, null if error. */ @JsonIgnore public Optional getMonitorId() { @@ -108,7 +108,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Monitor ID if successful, null if error.

+ *

Event monitor ID if successful, null if error.

*/ _FinalStage monitorId(Optional monitorId); @@ -147,7 +147,7 @@ public _FinalStage status(@NotNull String status) { } /** - *

Monitor ID if successful, null if error.

+ *

Event monitor ID if successful, null if error.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -163,7 +163,7 @@ public _FinalStage monitorId(Nullable monitorId) { } /** - *

Monitor ID if successful, null if error.

+ *

Event monitor ID if successful, null if error.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -173,7 +173,7 @@ public _FinalStage monitorId(String monitorId) { } /** - *

Monitor ID if successful, null if error.

+ *

Event monitor ID if successful, null if error.

*/ @java.lang.Override @JsonSetter(value = "monitor_id", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java b/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java index 180dde6..eace4c5 100644 --- a/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java @@ -62,7 +62,7 @@ public Optional getMessage() { } /** - * @return ID of the deleted monitor. null on failure. + * @return ID of the deleted event monitor. null on failure. */ @JsonIgnore public Optional getMonitorId() { @@ -139,7 +139,7 @@ public interface _FinalStage { _FinalStage message(Nullable message); /** - *

ID of the deleted monitor. null on failure.

+ *

ID of the deleted event monitor. null on failure.

*/ _FinalStage monitorId(Optional monitorId); @@ -181,7 +181,7 @@ public _FinalStage success(boolean success) { } /** - *

ID of the deleted monitor. null on failure.

+ *

ID of the deleted event monitor. null on failure.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -197,7 +197,7 @@ public _FinalStage monitorId(Nullable monitorId) { } /** - *

ID of the deleted monitor. null on failure.

+ *

ID of the deleted event monitor. null on failure.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -207,7 +207,7 @@ public _FinalStage monitorId(String monitorId) { } /** - *

ID of the deleted monitor. null on failure.

+ *

ID of the deleted event monitor. null on failure.

*/ @java.lang.Override @JsonSetter(value = "monitor_id", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java index 61d0058..8a58809 100644 --- a/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java +++ b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java @@ -109,7 +109,7 @@ public String getResourceId() { } /** - * @return Extra context about the triggering event, such as job query or monitor schedule. + * @return Extra context about the triggering event, such as job query or event monitor schedule. */ @JsonProperty("additional_info") public Optional> getAdditionalInfo() { @@ -298,7 +298,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Extra context about the triggering event, such as job query or monitor schedule.

+ *

Extra context about the triggering event, such as job query or event monitor schedule.

*/ _FinalStage additionalInfo(Optional> additionalInfo); @@ -538,7 +538,7 @@ public _FinalStage errorMessage(Optional errorMessage) { } /** - *

Extra context about the triggering event, such as job query or monitor schedule.

+ *

Extra context about the triggering event, such as job query or event monitor schedule.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -548,7 +548,7 @@ public _FinalStage additionalInfo(Map additionalInfo) { } /** - *

Extra context about the triggering event, such as job query or monitor schedule.

+ *

Extra context about the triggering event, such as job query or event monitor schedule.

*/ @java.lang.Override @JsonSetter(value = "additional_info", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/EventTags.java b/src/main/java/com/newscatcher/catchall/types/EventTags.java new file mode 100644 index 0000000..ce6fa9d --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/EventTags.java @@ -0,0 +1,186 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.Nullable; +import com.newscatcher.catchall.core.NullableNonemptyFilter; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = EventTags.Builder.class) +public final class EventTags { + private final Optional eventType; + + private final Optional sector; + + private final Map additionalProperties; + + private EventTags(Optional eventType, Optional sector, Map additionalProperties) { + this.eventType = eventType; + this.sector = sector; + this.additionalProperties = additionalProperties; + } + + /** + * @return Taxonomy path describing what happened, drawn from a fixed vocabulary. + * unclassifiable when no path fits. + */ + @JsonIgnore + public Optional getEventType() { + if (eventType == null) { + return Optional.empty(); + } + return eventType; + } + + /** + * @return Industry sector the event belongs to, drawn from a fixed vocabulary. + * other_sector when no sector fits. + */ + @JsonIgnore + public Optional getSector() { + if (sector == null) { + return Optional.empty(); + } + return sector; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("event_type") + private Optional _getEventType() { + return eventType; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("sector") + private Optional _getSector() { + return sector; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EventTags && equalTo((EventTags) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EventTags other) { + return eventType.equals(other.eventType) && sector.equals(other.sector); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventType, this.sector); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional eventType = Optional.empty(); + + private Optional sector = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(EventTags other) { + eventType(other.getEventType()); + sector(other.getSector()); + return this; + } + + /** + *

Taxonomy path describing what happened, drawn from a fixed vocabulary. + * unclassifiable when no path fits.

+ */ + @JsonSetter(value = "event_type", nulls = Nulls.SKIP) + public Builder eventType(Optional eventType) { + this.eventType = eventType; + return this; + } + + public Builder eventType(String eventType) { + this.eventType = Optional.ofNullable(eventType); + return this; + } + + public Builder eventType(Nullable eventType) { + if (eventType.isNull()) { + this.eventType = null; + } else if (eventType.isEmpty()) { + this.eventType = Optional.empty(); + } else { + this.eventType = Optional.of(eventType.get()); + } + return this; + } + + /** + *

Industry sector the event belongs to, drawn from a fixed vocabulary. + * other_sector when no sector fits.

+ */ + @JsonSetter(value = "sector", nulls = Nulls.SKIP) + public Builder sector(Optional sector) { + this.sector = sector; + return this; + } + + public Builder sector(String sector) { + this.sector = Optional.ofNullable(sector); + return this; + } + + public Builder sector(Nullable sector) { + if (sector.isNull()) { + this.sector = null; + } else if (sector.isEmpty()) { + this.sector = Optional.empty(); + } else { + this.sector = Optional.of(sector.get()); + } + return this; + } + + public EventTags build() { + return new EventTags(eventType, sector, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/ListMonitorsResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ListMonitorsResponseDto.java index c9f3696..76da96f 100644 --- a/src/main/java/com/newscatcher/catchall/types/ListMonitorsResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/ListMonitorsResponseDto.java @@ -49,7 +49,7 @@ private ListMonitorsResponseDto( } /** - * @return Total number of monitors for this user. + * @return Total number of event monitors for this user. */ @JsonProperty("total") public int getTotal() { @@ -65,7 +65,7 @@ public int getPage() { } /** - * @return Number of monitors per page. + * @return Number of event monitors per page. */ @JsonProperty("page_size") public int getPageSize() { @@ -81,7 +81,7 @@ public int getTotalPages() { } /** - * @return Array of monitor summaries. + * @return Array of event monitor summaries. */ @JsonProperty("monitors") public List getMonitors() { @@ -123,7 +123,7 @@ public static TotalStage builder() { public interface TotalStage { /** - *

Total number of monitors for this user.

+ *

Total number of event monitors for this user.

*/ PageStage total(int total); @@ -139,7 +139,7 @@ public interface PageStage { public interface PageSizeStage { /** - *

Number of monitors per page.

+ *

Number of event monitors per page.

*/ TotalPagesStage pageSize(int pageSize); } @@ -159,7 +159,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Array of monitor summaries.

+ *

Array of event monitor summaries.

*/ _FinalStage monitors(List monitors); @@ -196,7 +196,7 @@ public Builder from(ListMonitorsResponseDto other) { } /** - *

Total number of monitors for this user.

+ *

Total number of event monitors for this user.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -218,7 +218,7 @@ public PageSizeStage page(int page) { } /** - *

Number of monitors per page.

+ *

Number of event monitors per page.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -240,7 +240,7 @@ public _FinalStage totalPages(int totalPages) { } /** - *

Array of monitor summaries.

+ *

Array of event monitor summaries.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -252,7 +252,7 @@ public _FinalStage addAllMonitors(List monitors) { } /** - *

Array of monitor summaries.

+ *

Array of event monitor summaries.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -262,7 +262,7 @@ public _FinalStage addMonitors(MonitorListItemDto monitors) { } /** - *

Array of monitor summaries.

+ *

Array of event monitor summaries.

*/ @java.lang.Override @JsonSetter(value = "monitors", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/ListSourceGroupsResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ListSourceGroupsResponseDto.java new file mode 100644 index 0000000..01d7e71 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ListSourceGroupsResponseDto.java @@ -0,0 +1,260 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListSourceGroupsResponseDto.Builder.class) +public final class ListSourceGroupsResponseDto { + private final List sourceGroups; + + private final int total; + + private final int page; + + private final int pageSize; + + private final Map additionalProperties; + + private ListSourceGroupsResponseDto( + List sourceGroups, + int total, + int page, + int pageSize, + Map additionalProperties) { + this.sourceGroups = sourceGroups; + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Source groups visible to your organization. + */ + @JsonProperty("source_groups") + public List getSourceGroups() { + return sourceGroups; + } + + /** + * @return Total number of source groups available to your organization. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return The current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return The number of source groups per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSourceGroupsResponseDto && equalTo((ListSourceGroupsResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSourceGroupsResponseDto other) { + return sourceGroups.equals(other.sourceGroups) + && total == other.total + && page == other.page + && pageSize == other.pageSize; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceGroups, this.total, this.page, this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalStage builder() { + return new Builder(); + } + + public interface TotalStage { + /** + *

Total number of source groups available to your organization.

+ */ + PageStage total(int total); + + Builder from(ListSourceGroupsResponseDto other); + } + + public interface PageStage { + /** + *

The current page number.

+ */ + PageSizeStage page(int page); + } + + public interface PageSizeStage { + /** + *

The number of source groups per page.

+ */ + _FinalStage pageSize(int pageSize); + } + + public interface _FinalStage { + ListSourceGroupsResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Source groups visible to your organization.

+ */ + _FinalStage sourceGroups(List sourceGroups); + + _FinalStage addSourceGroups(SourceGroupRef sourceGroups); + + _FinalStage addAllSourceGroups(List sourceGroups); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalStage, PageStage, PageSizeStage, _FinalStage { + private int total; + + private int page; + + private int pageSize; + + private List sourceGroups = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListSourceGroupsResponseDto other) { + sourceGroups(other.getSourceGroups()); + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + /** + *

Total number of source groups available to your organization.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("total") + public PageStage total(int total) { + this.total = total; + return this; + } + + /** + *

The current page number.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("page") + public PageSizeStage page(int page) { + this.page = page; + return this; + } + + /** + *

The number of source groups per page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("page_size") + public _FinalStage pageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + *

Source groups visible to your organization.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllSourceGroups(List sourceGroups) { + if (sourceGroups != null) { + this.sourceGroups.addAll(sourceGroups); + } + return this; + } + + /** + *

Source groups visible to your organization.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addSourceGroups(SourceGroupRef sourceGroups) { + this.sourceGroups.add(sourceGroups); + return this; + } + + /** + *

Source groups visible to your organization.

+ */ + @java.lang.Override + @JsonSetter(value = "source_groups", nulls = Nulls.SKIP) + public _FinalStage sourceGroups(List sourceGroups) { + this.sourceGroups.clear(); + if (sourceGroups != null) { + this.sourceGroups.addAll(sourceGroups); + } + return this; + } + + @java.lang.Override + public ListSourceGroupsResponseDto build() { + return new ListSourceGroupsResponseDto(sourceGroups, total, page, pageSize, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorJobItem.java b/src/main/java/com/newscatcher/catchall/types/MonitorJobItem.java index 60f9186..7939abd 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorJobItem.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorJobItem.java @@ -45,7 +45,7 @@ public String getJobId() { } /** - * @return Start of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone. + * @return Start of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone. */ @JsonProperty("start_date") public OffsetDateTime getStartDate() { @@ -53,7 +53,7 @@ public OffsetDateTime getStartDate() { } /** - * @return End of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone. + * @return End of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone. */ @JsonProperty("end_date") public OffsetDateTime getEndDate() { @@ -100,14 +100,14 @@ public interface JobIdStage { public interface StartDateStage { /** - *

Start of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone.

+ *

Start of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone.

*/ EndDateStage startDate(@NotNull OffsetDateTime startDate); } public interface EndDateStage { /** - *

End of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone.

+ *

End of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone.

*/ _FinalStage endDate(@NotNull OffsetDateTime endDate); } @@ -153,7 +153,7 @@ public StartDateStage jobId(@NotNull String jobId) { } /** - *

Start of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone.

+ *

Start of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -164,7 +164,7 @@ public EndDateStage startDate(@NotNull OffsetDateTime startDate) { } /** - *

End of the data collection time window for this job execution (based on monitor schedule) in ISO 8601 format with UTC timezone.

+ *

End of the data collection time window for this job execution (based on event monitor schedule) in ISO 8601 format with UTC timezone.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java b/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java index d72188d..5b531bd 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java @@ -77,7 +77,7 @@ private MonitorListItemDto( } /** - * @return Monitor identifier. + * @return Event monitor identifier. */ @JsonProperty("monitor_id") public String getMonitorId() { @@ -85,7 +85,7 @@ public String getMonitorId() { } /** - * @return Job identifier used as a reference for this monitor. + * @return Job identifier used as a reference for this event monitor. */ @JsonProperty("reference_job_id") public String getReferenceJobId() { @@ -101,7 +101,7 @@ public String getReferenceJobQuery() { } /** - * @return True if the monitor is currently active; false otherwise. + * @return True if the event monitor is currently active; false otherwise. */ @JsonProperty("enabled") public boolean getEnabled() { @@ -109,7 +109,7 @@ public boolean getEnabled() { } /** - * @return Cron expression for monitor schedule. + * @return Cron expression for event monitor schedule. */ @JsonProperty("schedule") public Optional getSchedule() { @@ -117,7 +117,7 @@ public Optional getSchedule() { } /** - * @return The monitor schedule in a plain text format. + * @return The event monitor schedule in a plain text format. */ @JsonProperty("schedule_human_readable") public Optional getScheduleHumanReadable() { @@ -133,7 +133,7 @@ public Optional getTimezone() { } /** - * @return The date when the monitor was created. + * @return The date when the event monitor was created. */ @JsonProperty("created_at") public Optional getCreatedAt() { @@ -141,7 +141,7 @@ public Optional getCreatedAt() { } /** - * @return Webhook configuration for this monitor, or null if not set. + * @return Webhook configuration for this event monitor, or null if not set. */ @JsonIgnore public Optional getWebhook() { @@ -152,7 +152,7 @@ public Optional getWebhook() { } /** - * @return Masked API key associated with this monitor. + * @return Masked API key associated with this event monitor. */ @JsonProperty("user_key") public Optional getUserKey() { @@ -160,7 +160,7 @@ public Optional getUserKey() { } /** - * @return Present when this monitor was shared with the authenticated user. Omitted when the user owns the monitor. + * @return Present when this event monitor was shared with the authenticated user. Omitted when the user owns the event monitor. */ @JsonProperty("sharing_info") public Optional getSharingInfo() { @@ -225,7 +225,7 @@ public static MonitorIdStage builder() { public interface MonitorIdStage { /** - *

Monitor identifier.

+ *

Event monitor identifier.

*/ ReferenceJobIdStage monitorId(@NotNull String monitorId); @@ -234,7 +234,7 @@ public interface MonitorIdStage { public interface ReferenceJobIdStage { /** - *

Job identifier used as a reference for this monitor.

+ *

Job identifier used as a reference for this event monitor.

*/ ReferenceJobQueryStage referenceJobId(@NotNull String referenceJobId); } @@ -248,7 +248,7 @@ public interface ReferenceJobQueryStage { public interface EnabledStage { /** - *

True if the monitor is currently active; false otherwise.

+ *

True if the event monitor is currently active; false otherwise.

*/ _FinalStage enabled(boolean enabled); } @@ -261,14 +261,14 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Cron expression for monitor schedule.

+ *

Cron expression for event monitor schedule.

*/ _FinalStage schedule(Optional schedule); _FinalStage schedule(String schedule); /** - *

The monitor schedule in a plain text format.

+ *

The event monitor schedule in a plain text format.

*/ _FinalStage scheduleHumanReadable(Optional scheduleHumanReadable); @@ -282,14 +282,14 @@ public interface _FinalStage { _FinalStage timezone(String timezone); /** - *

The date when the monitor was created.

+ *

The date when the event monitor was created.

*/ _FinalStage createdAt(Optional createdAt); _FinalStage createdAt(OffsetDateTime createdAt); /** - *

Webhook configuration for this monitor, or null if not set.

+ *

Webhook configuration for this event monitor, or null if not set.

*/ _FinalStage webhook(Optional webhook); @@ -298,14 +298,14 @@ public interface _FinalStage { _FinalStage webhook(Nullable webhook); /** - *

Masked API key associated with this monitor.

+ *

Masked API key associated with this event monitor.

*/ _FinalStage userKey(Optional userKey); _FinalStage userKey(String userKey); /** - *

Present when this monitor was shared with the authenticated user. Omitted when the user owns the monitor.

+ *

Present when this event monitor was shared with the authenticated user. Omitted when the user owns the event monitor.

*/ _FinalStage sharingInfo(Optional sharingInfo); @@ -359,7 +359,7 @@ public Builder from(MonitorListItemDto other) { } /** - *

Monitor identifier.

+ *

Event monitor identifier.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -370,7 +370,7 @@ public ReferenceJobIdStage monitorId(@NotNull String monitorId) { } /** - *

Job identifier used as a reference for this monitor.

+ *

Job identifier used as a reference for this event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -392,7 +392,7 @@ public EnabledStage referenceJobQuery(@NotNull String referenceJobQuery) { } /** - *

True if the monitor is currently active; false otherwise.

+ *

True if the event monitor is currently active; false otherwise.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -403,7 +403,7 @@ public _FinalStage enabled(boolean enabled) { } /** - *

Present when this monitor was shared with the authenticated user. Omitted when the user owns the monitor.

+ *

Present when this event monitor was shared with the authenticated user. Omitted when the user owns the event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -413,7 +413,7 @@ public _FinalStage sharingInfo(SharingInfo sharingInfo) { } /** - *

Present when this monitor was shared with the authenticated user. Omitted when the user owns the monitor.

+ *

Present when this event monitor was shared with the authenticated user. Omitted when the user owns the event monitor.

*/ @java.lang.Override @JsonSetter(value = "sharing_info", nulls = Nulls.SKIP) @@ -423,7 +423,7 @@ public _FinalStage sharingInfo(Optional sharingInfo) { } /** - *

Masked API key associated with this monitor.

+ *

Masked API key associated with this event monitor.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -433,7 +433,7 @@ public _FinalStage userKey(String userKey) { } /** - *

Masked API key associated with this monitor.

+ *

Masked API key associated with this event monitor.

*/ @java.lang.Override @JsonSetter(value = "user_key", nulls = Nulls.SKIP) @@ -443,7 +443,7 @@ public _FinalStage userKey(Optional userKey) { } /** - *

Webhook configuration for this monitor, or null if not set.

+ *

Webhook configuration for this event monitor, or null if not set.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -459,7 +459,7 @@ public _FinalStage webhook(Nullable webhook) { } /** - *

Webhook configuration for this monitor, or null if not set.

+ *

Webhook configuration for this event monitor, or null if not set.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -469,7 +469,7 @@ public _FinalStage webhook(WebhookDto webhook) { } /** - *

Webhook configuration for this monitor, or null if not set.

+ *

Webhook configuration for this event monitor, or null if not set.

*/ @java.lang.Override @JsonSetter(value = "webhook", nulls = Nulls.SKIP) @@ -479,7 +479,7 @@ public _FinalStage webhook(Optional webhook) { } /** - *

The date when the monitor was created.

+ *

The date when the event monitor was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -489,7 +489,7 @@ public _FinalStage createdAt(OffsetDateTime createdAt) { } /** - *

The date when the monitor was created.

+ *

The date when the event monitor was created.

*/ @java.lang.Override @JsonSetter(value = "created_at", nulls = Nulls.SKIP) @@ -519,7 +519,7 @@ public _FinalStage timezone(Optional timezone) { } /** - *

The monitor schedule in a plain text format.

+ *

The event monitor schedule in a plain text format.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -529,7 +529,7 @@ public _FinalStage scheduleHumanReadable(String scheduleHumanReadable) { } /** - *

The monitor schedule in a plain text format.

+ *

The event monitor schedule in a plain text format.

*/ @java.lang.Override @JsonSetter(value = "schedule_human_readable", nulls = Nulls.SKIP) @@ -539,7 +539,7 @@ public _FinalStage scheduleHumanReadable(Optional scheduleHumanReadable) } /** - *

Cron expression for monitor schedule.

+ *

Cron expression for event monitor schedule.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -549,7 +549,7 @@ public _FinalStage schedule(String schedule) { } /** - *

Cron expression for monitor schedule.

+ *

Cron expression for event monitor schedule.

*/ @java.lang.Override @JsonSetter(value = "schedule", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorRecord.java b/src/main/java/com/newscatcher/catchall/types/MonitorRecord.java index a717b76..9cf7059 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorRecord.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorRecord.java @@ -76,7 +76,7 @@ public String getRecordTitle() { /** * @return Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content. *

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

*/ @JsonProperty("enrichment") public BaseRecordEnrichment getEnrichment() { @@ -84,7 +84,7 @@ public BaseRecordEnrichment getEnrichment() { } /** - * @return Source documents with monitor-specific metadata (job_id, added_on timestamps). + * @return Source documents with event monitor-specific metadata (job_id, added_on timestamps). */ @JsonProperty("citations") public List getCitations() { @@ -92,7 +92,7 @@ public List getCitations() { } /** - * @return The date when this record was first added to monitor results in ISO 8601 format with UTC timezone. + * @return The date when this record was first added to event monitor results in ISO 8601 format with UTC timezone. */ @JsonProperty("added_on") public Optional getAddedOn() { @@ -100,7 +100,7 @@ public Optional getAddedOn() { } /** - * @return The date when this record was last updated in monitor results in ISO 8601 format with UTC timezone. + * @return The date when this record was last updated in event monitor results in ISO 8601 format with UTC timezone. */ @JsonProperty("updated_on") public Optional getUpdatedOn() { @@ -162,7 +162,7 @@ public interface EnrichmentStage { /** *

Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

*

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

*/ _FinalStage enrichment(@NotNull BaseRecordEnrichment enrichment); } @@ -175,7 +175,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

Source documents with monitor-specific metadata (job_id, added_on timestamps).

+ *

Source documents with event monitor-specific metadata (job_id, added_on timestamps).

*/ _FinalStage citations(List citations); @@ -184,14 +184,14 @@ public interface _FinalStage { _FinalStage addAllCitations(List citations); /** - *

The date when this record was first added to monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was first added to event monitor results in ISO 8601 format with UTC timezone.

*/ _FinalStage addedOn(Optional addedOn); _FinalStage addedOn(OffsetDateTime addedOn); /** - *

The date when this record was last updated in monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was last updated in event monitor results in ISO 8601 format with UTC timezone.

*/ _FinalStage updatedOn(Optional updatedOn); @@ -253,7 +253,7 @@ public EnrichmentStage recordTitle(@NotNull String recordTitle) { /** *

Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

*

Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

- *

For integration guidance, see Dynamic schemas

+ *

For integration guidance, see Dynamic schemas

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -264,7 +264,7 @@ public _FinalStage enrichment(@NotNull BaseRecordEnrichment enrichment) { } /** - *

The date when this record was last updated in monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was last updated in event monitor results in ISO 8601 format with UTC timezone.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -274,7 +274,7 @@ public _FinalStage updatedOn(OffsetDateTime updatedOn) { } /** - *

The date when this record was last updated in monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was last updated in event monitor results in ISO 8601 format with UTC timezone.

*/ @java.lang.Override @JsonSetter(value = "updated_on", nulls = Nulls.SKIP) @@ -284,7 +284,7 @@ public _FinalStage updatedOn(Optional updatedOn) { } /** - *

The date when this record was first added to monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was first added to event monitor results in ISO 8601 format with UTC timezone.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -294,7 +294,7 @@ public _FinalStage addedOn(OffsetDateTime addedOn) { } /** - *

The date when this record was first added to monitor results in ISO 8601 format with UTC timezone.

+ *

The date when this record was first added to event monitor results in ISO 8601 format with UTC timezone.

*/ @java.lang.Override @JsonSetter(value = "added_on", nulls = Nulls.SKIP) @@ -304,7 +304,7 @@ public _FinalStage addedOn(Optional addedOn) { } /** - *

Source documents with monitor-specific metadata (job_id, added_on timestamps).

+ *

Source documents with event monitor-specific metadata (job_id, added_on timestamps).

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -316,7 +316,7 @@ public _FinalStage addAllCitations(List citations) { } /** - *

Source documents with monitor-specific metadata (job_id, added_on timestamps).

+ *

Source documents with event monitor-specific metadata (job_id, added_on timestamps).

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -326,7 +326,7 @@ public _FinalStage addCitations(MonitorCitation citations) { } /** - *

Source documents with monitor-specific metadata (job_id, added_on timestamps).

+ *

Source documents with event monitor-specific metadata (job_id, added_on timestamps).

*/ @java.lang.Override @JsonSetter(value = "citations", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorStatusEntry.java b/src/main/java/com/newscatcher/catchall/types/MonitorStatusEntry.java index a3df845..d311f04 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorStatusEntry.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorStatusEntry.java @@ -47,9 +47,9 @@ private MonitorStatusEntry( /** * @return Type of lifecycle event. *
    - *
  • created: Monitor was created.
  • - *
  • enable: Monitor was enabled.
  • - *
  • disable: Monitor was disabled.
  • + *
  • created: Event monitor was created.
  • + *
  • enable: Event monitor was enabled.
  • + *
  • disable: Event monitor was disabled.
  • *
  • scheduled: A job was triggered for execution. * additional_information contains job_id, start_date, * and end_date.
  • @@ -91,7 +91,7 @@ public OffsetDateTime getCreatedAt() { * } * } * - *

    The webhook key is only present if the monitor has a webhook configured.

    + *

    The webhook key is only present if the event monitor has a webhook configured.

    */ @JsonIgnore public Optional> getAdditionalInformation() { @@ -142,9 +142,9 @@ public interface StatusStage { /** *

    Type of lifecycle event.

    *
      - *
    • created: Monitor was created.
    • - *
    • enable: Monitor was enabled.
    • - *
    • disable: Monitor was disabled.
    • + *
    • created: Event monitor was created.
    • + *
    • enable: Event monitor was enabled.
    • + *
    • disable: Event monitor was disabled.
    • *
    • scheduled: A job was triggered for execution. * additional_information contains job_id, start_date, * and end_date.
    • @@ -192,7 +192,7 @@ public interface _FinalStage { * } * } * - *

      The webhook key is only present if the monitor has a webhook configured.

      + *

      The webhook key is only present if the event monitor has a webhook configured.

      */ _FinalStage additionalInformation(Optional> additionalInformation); @@ -225,9 +225,9 @@ public Builder from(MonitorStatusEntry other) { /** *

      Type of lifecycle event.

      *
        - *
      • created: Monitor was created.
      • - *
      • enable: Monitor was enabled.
      • - *
      • disable: Monitor was disabled.
      • + *
      • created: Event monitor was created.
      • + *
      • enable: Event monitor was enabled.
      • + *
      • disable: Event monitor was disabled.
      • *
      • scheduled: A job was triggered for execution. * additional_information contains job_id, start_date, * and end_date.
      • @@ -275,7 +275,7 @@ public _FinalStage createdAt(@NotNull OffsetDateTime createdAt) { * } * } * - *

        The webhook key is only present if the monitor has a webhook configured.

        + *

        The webhook key is only present if the event monitor has a webhook configured.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -310,7 +310,7 @@ public _FinalStage additionalInformation(Nullable> additiona * } * } * - *

        The webhook key is only present if the monitor has a webhook configured.

        + *

        The webhook key is only present if the event monitor has a webhook configured.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -339,7 +339,7 @@ public _FinalStage additionalInformation(Map additionalInformati * } * } * - *

        The webhook key is only present if the monitor has a webhook configured.

        + *

        The webhook key is only present if the event monitor has a webhook configured.

        */ @java.lang.Override @JsonSetter(value = "additional_information", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java b/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java index 1e755a7..8860e20 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java @@ -71,7 +71,7 @@ public Optional getMessage() { } /** - * @return Monitor identifier. null on failure. + * @return Event monitor identifier. null on failure. */ @JsonIgnore public Optional getMonitorId() { @@ -186,7 +186,7 @@ public interface _FinalStage { _FinalStage message(Nullable message); /** - *

        Monitor identifier. null on failure.

        + *

        Event monitor identifier. null on failure.

        */ _FinalStage monitorId(Optional monitorId); @@ -324,7 +324,7 @@ public _FinalStage totalStatuses(Optional totalStatuses) { } /** - *

        Monitor identifier. null on failure.

        + *

        Event monitor identifier. null on failure.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -340,7 +340,7 @@ public _FinalStage monitorId(Nullable monitorId) { } /** - *

        Monitor identifier. null on failure.

        + *

        Event monitor identifier. null on failure.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -350,7 +350,7 @@ public _FinalStage monitorId(String monitorId) { } /** - *

        Monitor identifier. null on failure.

        + *

        Event monitor identifier. null on failure.

        */ @java.lang.Override @JsonSetter(value = "monitor_id", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/PullJobResponseDto.java b/src/main/java/com/newscatcher/catchall/types/PullJobResponseDto.java index e8b20f4..53dff2a 100644 --- a/src/main/java/com/newscatcher/catchall/types/PullJobResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/PullJobResponseDto.java @@ -61,6 +61,8 @@ public final class PullJobResponseDto { private final Optional> connectedDatasets; + private final Optional> sourceGroups; + private final Optional isAllNewsQuery; private final Optional sharingInfo; @@ -88,6 +90,7 @@ private PullJobResponseDto( Optional totalPages, Optional mode, Optional> connectedDatasets, + Optional> sourceGroups, Optional isAllNewsQuery, Optional sharingInfo, Optional> allRecords, @@ -110,6 +113,7 @@ private PullJobResponseDto( this.totalPages = totalPages; this.mode = mode; this.connectedDatasets = connectedDatasets; + this.sourceGroups = sourceGroups; this.isAllNewsQuery = isAllNewsQuery; this.sharingInfo = sharingInfo; this.allRecords = allRecords; @@ -264,6 +268,18 @@ public Optional> getConnectedDatasets() { return connectedDatasets; } + /** + * @return Source groups attached to this job, each with slug, name, and description. + * null when the job was not scoped to any source group. + */ + @JsonIgnore + public Optional> getSourceGroups() { + if (sourceGroups == null) { + return Optional.empty(); + } + return sourceGroups; + } + /** * @return True when the query was submitted as an all-news (watchlist-generic) query. */ @@ -303,6 +319,12 @@ private Optional _getProgressValidated() { return progressValidated; } + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("source_groups") + private Optional> _getSourceGroups() { + return sourceGroups; + } + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) @JsonProperty("sharing_info") private Optional _getSharingInfo() { @@ -339,6 +361,7 @@ private boolean equalTo(PullJobResponseDto other) { && totalPages.equals(other.totalPages) && mode.equals(other.mode) && connectedDatasets.equals(other.connectedDatasets) + && sourceGroups.equals(other.sourceGroups) && isAllNewsQuery.equals(other.isAllNewsQuery) && sharingInfo.equals(other.sharingInfo) && allRecords.equals(other.allRecords); @@ -365,6 +388,7 @@ public int hashCode() { this.totalPages, this.mode, this.connectedDatasets, + this.sourceGroups, this.isAllNewsQuery, this.sharingInfo, this.allRecords); @@ -516,6 +540,16 @@ public interface _FinalStage { _FinalStage connectedDatasets(List connectedDatasets); + /** + *

        Source groups attached to this job, each with slug, name, and description. + * null when the job was not scoped to any source group.

        + */ + _FinalStage sourceGroups(Optional> sourceGroups); + + _FinalStage sourceGroups(List sourceGroups); + + _FinalStage sourceGroups(Nullable> sourceGroups); + /** *

        True when the query was submitted as an all-news (watchlist-generic) query.

        */ @@ -550,6 +584,8 @@ public static final class Builder implements JobIdStage, _FinalStage { private Optional isAllNewsQuery = Optional.empty(); + private Optional> sourceGroups = Optional.empty(); + private Optional> connectedDatasets = Optional.empty(); private Optional mode = Optional.empty(); @@ -609,6 +645,7 @@ public Builder from(PullJobResponseDto other) { totalPages(other.getTotalPages()); mode(other.getMode()); connectedDatasets(other.getConnectedDatasets()); + sourceGroups(other.getSourceGroups()); isAllNewsQuery(other.getIsAllNewsQuery()); sharingInfo(other.getSharingInfo()); allRecords(other.getAllRecords()); @@ -702,6 +739,45 @@ public _FinalStage isAllNewsQuery(Optional isAllNewsQuery) { return this; } + /** + *

        Source groups attached to this job, each with slug, name, and description. + * null when the job was not scoped to any source group.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sourceGroups(Nullable> sourceGroups) { + if (sourceGroups.isNull()) { + this.sourceGroups = null; + } else if (sourceGroups.isEmpty()) { + this.sourceGroups = Optional.empty(); + } else { + this.sourceGroups = Optional.of(sourceGroups.get()); + } + return this; + } + + /** + *

        Source groups attached to this job, each with slug, name, and description. + * null when the job was not scoped to any source group.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sourceGroups(List sourceGroups) { + this.sourceGroups = Optional.ofNullable(sourceGroups); + return this; + } + + /** + *

        Source groups attached to this job, each with slug, name, and description. + * null when the job was not scoped to any source group.

        + */ + @java.lang.Override + @JsonSetter(value = "source_groups", nulls = Nulls.SKIP) + public _FinalStage sourceGroups(Optional> sourceGroups) { + this.sourceGroups = sourceGroups; + return this; + } + /** *

        Datasets used to narrow retrieval scope, each with id and name.

        * @return Reference to {@code this} so that method calls can be chained together. @@ -1091,6 +1167,7 @@ public PullJobResponseDto build() { totalPages, mode, connectedDatasets, + sourceGroups, isAllNewsQuery, sharingInfo, allRecords, diff --git a/src/main/java/com/newscatcher/catchall/types/PullMonitorResponseDto.java b/src/main/java/com/newscatcher/catchall/types/PullMonitorResponseDto.java index 4f6a567..acdbd31 100644 --- a/src/main/java/com/newscatcher/catchall/types/PullMonitorResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/PullMonitorResponseDto.java @@ -77,7 +77,7 @@ private PullMonitorResponseDto( } /** - * @return Unique identifier for the monitor. + * @return Unique identifier for the event monitor. */ @JsonProperty("monitor_id") public String getMonitorId() { @@ -85,7 +85,7 @@ public String getMonitorId() { } /** - * @return The cron expression for a monitor schedule parsed from the text schedule you provide. + * @return The cron expression for an event monitor schedule parsed from the text schedule you provide. *

        Standard cron format (minute hour day month day-of-week).

        */ @JsonProperty("cron_expression") @@ -107,7 +107,7 @@ public ReferenceJob getReferenceJob() { } /** - * @return Execution time range for this monitor. + * @return Execution time range for this event monitor. */ @JsonProperty("run_info") public Optional getRunInfo() { @@ -115,7 +115,7 @@ public Optional getRunInfo() { } /** - * @return Total number of records collected across all monitor jobs. + * @return Total number of records collected across all event monitor jobs. */ @JsonProperty("records") public Optional getRecords() { @@ -123,7 +123,7 @@ public Optional getRecords() { } /** - * @return Current monitor status or error message if monitor creation failed. + * @return Current event monitor status or error message if event monitor creation failed. */ @JsonProperty("status") public String getStatus() { @@ -131,7 +131,7 @@ public String getStatus() { } /** - * @return Aggregated records from all jobs executed by this monitor. Each record includes structured data extracted from web sources with citations. + * @return Aggregated records from all jobs executed by this event monitor. Each record includes structured data extracted from web sources with citations. */ @JsonProperty("all_records") public Optional> getAllRecords() { @@ -139,7 +139,7 @@ public Optional> getAllRecords() { } /** - * @return Record limit applied to this monitor's jobs. + * @return Record limit applied to this event monitor's jobs. */ @JsonIgnore public Optional getLimit() { @@ -223,7 +223,7 @@ public static MonitorIdStage builder() { public interface MonitorIdStage { /** - *

        Unique identifier for the monitor.

        + *

        Unique identifier for the event monitor.

        */ ReferenceJobStage monitorId(@NotNull String monitorId); @@ -236,7 +236,7 @@ public interface ReferenceJobStage { public interface StatusStage { /** - *

        Current monitor status or error message if monitor creation failed.

        + *

        Current event monitor status or error message if event monitor creation failed.

        */ _FinalStage status(@NotNull String status); } @@ -249,7 +249,7 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); /** - *

        The cron expression for a monitor schedule parsed from the text schedule you provide.

        + *

        The cron expression for an event monitor schedule parsed from the text schedule you provide.

        *

        Standard cron format (minute hour day month day-of-week).

        */ _FinalStage cronExpression(Optional cronExpression); @@ -264,28 +264,28 @@ public interface _FinalStage { _FinalStage timezone(String timezone); /** - *

        Execution time range for this monitor.

        + *

        Execution time range for this event monitor.

        */ _FinalStage runInfo(Optional runInfo); _FinalStage runInfo(PullMonitorResponseDtoRunInfo runInfo); /** - *

        Total number of records collected across all monitor jobs.

        + *

        Total number of records collected across all event monitor jobs.

        */ _FinalStage records(Optional records); _FinalStage records(Integer records); /** - *

        Aggregated records from all jobs executed by this monitor. Each record includes structured data extracted from web sources with citations.

        + *

        Aggregated records from all jobs executed by this event monitor. Each record includes structured data extracted from web sources with citations.

        */ _FinalStage allRecords(Optional> allRecords); _FinalStage allRecords(List allRecords); /** - *

        Record limit applied to this monitor's jobs.

        + *

        Record limit applied to this event monitor's jobs.

        */ _FinalStage limit(Optional limit); @@ -354,7 +354,7 @@ public Builder from(PullMonitorResponseDto other) { } /** - *

        Unique identifier for the monitor.

        + *

        Unique identifier for the event monitor.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -372,7 +372,7 @@ public StatusStage referenceJob(@NotNull ReferenceJob referenceJob) { } /** - *

        Current monitor status or error message if monitor creation failed.

        + *

        Current event monitor status or error message if event monitor creation failed.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -423,7 +423,7 @@ public _FinalStage connectedDatasets(Optional> connectedD } /** - *

        Record limit applied to this monitor's jobs.

        + *

        Record limit applied to this event monitor's jobs.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -439,7 +439,7 @@ public _FinalStage limit(Nullable limit) { } /** - *

        Record limit applied to this monitor's jobs.

        + *

        Record limit applied to this event monitor's jobs.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -449,7 +449,7 @@ public _FinalStage limit(Integer limit) { } /** - *

        Record limit applied to this monitor's jobs.

        + *

        Record limit applied to this event monitor's jobs.

        */ @java.lang.Override @JsonSetter(value = "limit", nulls = Nulls.SKIP) @@ -459,7 +459,7 @@ public _FinalStage limit(Optional limit) { } /** - *

        Aggregated records from all jobs executed by this monitor. Each record includes structured data extracted from web sources with citations.

        + *

        Aggregated records from all jobs executed by this event monitor. Each record includes structured data extracted from web sources with citations.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -469,7 +469,7 @@ public _FinalStage allRecords(List allRecords) { } /** - *

        Aggregated records from all jobs executed by this monitor. Each record includes structured data extracted from web sources with citations.

        + *

        Aggregated records from all jobs executed by this event monitor. Each record includes structured data extracted from web sources with citations.

        */ @java.lang.Override @JsonSetter(value = "all_records", nulls = Nulls.SKIP) @@ -479,7 +479,7 @@ public _FinalStage allRecords(Optional> allRecords) { } /** - *

        Total number of records collected across all monitor jobs.

        + *

        Total number of records collected across all event monitor jobs.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -489,7 +489,7 @@ public _FinalStage records(Integer records) { } /** - *

        Total number of records collected across all monitor jobs.

        + *

        Total number of records collected across all event monitor jobs.

        */ @java.lang.Override @JsonSetter(value = "records", nulls = Nulls.SKIP) @@ -499,7 +499,7 @@ public _FinalStage records(Optional records) { } /** - *

        Execution time range for this monitor.

        + *

        Execution time range for this event monitor.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -509,7 +509,7 @@ public _FinalStage runInfo(PullMonitorResponseDtoRunInfo runInfo) { } /** - *

        Execution time range for this monitor.

        + *

        Execution time range for this event monitor.

        */ @java.lang.Override @JsonSetter(value = "run_info", nulls = Nulls.SKIP) @@ -539,7 +539,7 @@ public _FinalStage timezone(Optional timezone) { } /** - *

        The cron expression for a monitor schedule parsed from the text schedule you provide.

        + *

        The cron expression for an event monitor schedule parsed from the text schedule you provide.

        *

        Standard cron format (minute hour day month day-of-week).

        * @return Reference to {@code this} so that method calls can be chained together. */ @@ -550,7 +550,7 @@ public _FinalStage cronExpression(String cronExpression) { } /** - *

        The cron expression for a monitor schedule parsed from the text schedule you provide.

        + *

        The cron expression for an event monitor schedule parsed from the text schedule you provide.

        *

        Standard cron format (minute hour day month day-of-week).

        */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/types/Record.java b/src/main/java/com/newscatcher/catchall/types/Record.java index 445e4f8..e0d1155 100644 --- a/src/main/java/com/newscatcher/catchall/types/Record.java +++ b/src/main/java/com/newscatcher/catchall/types/Record.java @@ -5,12 +5,15 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.Nullable; +import com.newscatcher.catchall.core.NullableNonemptyFilter; import com.newscatcher.catchall.core.ObjectMappers; import java.util.ArrayList; import java.util.HashMap; @@ -33,6 +36,8 @@ public final class Record implements IBaseRecord { private final Optional> connectedEntities; + private final Optional tags; + private final Map additionalProperties; private Record( @@ -41,12 +46,14 @@ private Record( BaseRecordEnrichment enrichment, List citations, Optional> connectedEntities, + Optional tags, Map additionalProperties) { this.recordId = recordId; this.recordTitle = recordTitle; this.enrichment = enrichment; this.citations = citations; this.connectedEntities = connectedEntities; + this.tags = tags; this.additionalProperties = additionalProperties; } @@ -71,7 +78,7 @@ public String getRecordTitle() { /** * @return Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content. *

        Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

        - *

        For integration guidance, see Dynamic schemas

        + *

        For integration guidance, see Dynamic schemas

        */ @JsonProperty("enrichment") public BaseRecordEnrichment getEnrichment() { @@ -95,6 +102,26 @@ public Optional> getConnectedEntities() { return connectedEntities; } + /** + * @return Fixed-taxonomy classification of the event, as event_type and sector. + *

        Only present for all-news watchlist jobs — those submitted with + * fetch_all_watchlist_news: true, which the job pull response reports as + * is_all_news_query: true. Absent or null for every other job.

        + */ + @JsonIgnore + public Optional getTags() { + if (tags == null) { + return Optional.empty(); + } + return tags; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("tags") + private Optional _getTags() { + return tags; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -111,12 +138,14 @@ private boolean equalTo(Record other) { && recordTitle.equals(other.recordTitle) && enrichment.equals(other.enrichment) && citations.equals(other.citations) - && connectedEntities.equals(other.connectedEntities); + && connectedEntities.equals(other.connectedEntities) + && tags.equals(other.tags); } @java.lang.Override public int hashCode() { - return Objects.hash(this.recordId, this.recordTitle, this.enrichment, this.citations, this.connectedEntities); + return Objects.hash( + this.recordId, this.recordTitle, this.enrichment, this.citations, this.connectedEntities, this.tags); } @java.lang.Override @@ -148,7 +177,7 @@ public interface EnrichmentStage { /** *

        Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

        *

        Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

        - *

        For integration guidance, see Dynamic schemas

        + *

        For integration guidance, see Dynamic schemas

        */ _FinalStage enrichment(@NotNull BaseRecordEnrichment enrichment); } @@ -176,6 +205,18 @@ public interface _FinalStage { _FinalStage connectedEntities(Optional> connectedEntities); _FinalStage connectedEntities(List connectedEntities); + + /** + *

        Fixed-taxonomy classification of the event, as event_type and sector.

        + *

        Only present for all-news watchlist jobs — those submitted with + * fetch_all_watchlist_news: true, which the job pull response reports as + * is_all_news_query: true. Absent or null for every other job.

        + */ + _FinalStage tags(Optional tags); + + _FinalStage tags(EventTags tags); + + _FinalStage tags(Nullable tags); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -186,6 +227,8 @@ public static final class Builder implements RecordIdStage, RecordTitleStage, En private BaseRecordEnrichment enrichment; + private Optional tags = Optional.empty(); + private Optional> connectedEntities = Optional.empty(); private List citations = new ArrayList<>(); @@ -202,6 +245,7 @@ public Builder from(Record other) { enrichment(other.getEnrichment()); citations(other.getCitations()); connectedEntities(other.getConnectedEntities()); + tags(other.getTags()); return this; } @@ -230,7 +274,7 @@ public EnrichmentStage recordTitle(@NotNull String recordTitle) { /** *

        Structured data extracted from web pages. Schema is dynamically generated per job. Field names are chosen semantically to match the content.

        *

        Note: The system always includes the enrichment_confidence field within the enrichment object, regardless of whether enrichments are generated or specified by you.

        - *

        For integration guidance, see Dynamic schemas

        + *

        For integration guidance, see Dynamic schemas

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -240,6 +284,51 @@ public _FinalStage enrichment(@NotNull BaseRecordEnrichment enrichment) { return this; } + /** + *

        Fixed-taxonomy classification of the event, as event_type and sector.

        + *

        Only present for all-news watchlist jobs — those submitted with + * fetch_all_watchlist_news: true, which the job pull response reports as + * is_all_news_query: true. Absent or null for every other job.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tags(Nullable tags) { + if (tags.isNull()) { + this.tags = null; + } else if (tags.isEmpty()) { + this.tags = Optional.empty(); + } else { + this.tags = Optional.of(tags.get()); + } + return this; + } + + /** + *

        Fixed-taxonomy classification of the event, as event_type and sector.

        + *

        Only present for all-news watchlist jobs — those submitted with + * fetch_all_watchlist_news: true, which the job pull response reports as + * is_all_news_query: true. Absent or null for every other job.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tags(EventTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + /** + *

        Fixed-taxonomy classification of the event, as event_type and sector.

        + *

        Only present for all-news watchlist jobs — those submitted with + * fetch_all_watchlist_news: true, which the job pull response reports as + * is_all_news_query: true. Absent or null for every other job.

        + */ + @java.lang.Override + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public _FinalStage tags(Optional tags) { + this.tags = tags; + return this; + } + /** *

        Entities from the connected dataset that are relevant to this record. * Only present when the job was submitted with connected_dataset_ids.

        @@ -299,7 +388,8 @@ public _FinalStage citations(List citations) { @java.lang.Override public Record build() { - return new Record(recordId, recordTitle, enrichment, citations, connectedEntities, additionalProperties); + return new Record( + recordId, recordTitle, enrichment, citations, connectedEntities, tags, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/types/ReferenceJob.java b/src/main/java/com/newscatcher/catchall/types/ReferenceJob.java index 10b2060..96dc147 100644 --- a/src/main/java/com/newscatcher/catchall/types/ReferenceJob.java +++ b/src/main/java/com/newscatcher/catchall/types/ReferenceJob.java @@ -5,14 +5,18 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.Nullable; +import com.newscatcher.catchall.core.NullableNonemptyFilter; import com.newscatcher.catchall.core.ObjectMappers; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,11 +28,18 @@ public final class ReferenceJob { private final Optional context; + private final Optional> sourceGroups; + private final Map additionalProperties; - private ReferenceJob(Optional query, Optional context, Map additionalProperties) { + private ReferenceJob( + Optional query, + Optional context, + Optional> sourceGroups, + Map additionalProperties) { this.query = query; this.context = context; + this.sourceGroups = sourceGroups; this.additionalProperties = additionalProperties; } @@ -48,6 +59,24 @@ public Optional getContext() { return context; } + /** + * @return Source groups attached to the reference job, each with slug, name, and + * description. null when the reference job was not scoped to any source group. + */ + @JsonIgnore + public Optional> getSourceGroups() { + if (sourceGroups == null) { + return Optional.empty(); + } + return sourceGroups; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("source_groups") + private Optional> _getSourceGroups() { + return sourceGroups; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -60,12 +89,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ReferenceJob other) { - return query.equals(other.query) && context.equals(other.context); + return query.equals(other.query) && context.equals(other.context) && sourceGroups.equals(other.sourceGroups); } @java.lang.Override public int hashCode() { - return Objects.hash(this.query, this.context); + return Objects.hash(this.query, this.context, this.sourceGroups); } @java.lang.Override @@ -83,6 +112,8 @@ public static final class Builder { private Optional context = Optional.empty(); + private Optional> sourceGroups = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -91,6 +122,7 @@ private Builder() {} public Builder from(ReferenceJob other) { query(other.getQuery()); context(other.getContext()); + sourceGroups(other.getSourceGroups()); return this; } @@ -122,8 +154,34 @@ public Builder context(String context) { return this; } + /** + *

        Source groups attached to the reference job, each with slug, name, and + * description. null when the reference job was not scoped to any source group.

        + */ + @JsonSetter(value = "source_groups", nulls = Nulls.SKIP) + public Builder sourceGroups(Optional> sourceGroups) { + this.sourceGroups = sourceGroups; + return this; + } + + public Builder sourceGroups(List sourceGroups) { + this.sourceGroups = Optional.ofNullable(sourceGroups); + return this; + } + + public Builder sourceGroups(Nullable> sourceGroups) { + if (sourceGroups.isNull()) { + this.sourceGroups = null; + } else if (sourceGroups.isEmpty()) { + this.sourceGroups = Optional.empty(); + } else { + this.sourceGroups = Optional.of(sourceGroups.get()); + } + return this; + } + public ReferenceJob build() { - return new ReferenceJob(query, context, additionalProperties); + return new ReferenceJob(query, context, sourceGroups, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/newscatcher/catchall/types/SourceGroupRef.java b/src/main/java/com/newscatcher/catchall/types/SourceGroupRef.java new file mode 100644 index 0000000..8592848 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/SourceGroupRef.java @@ -0,0 +1,237 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.Nullable; +import com.newscatcher.catchall.core.NullableNonemptyFilter; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SourceGroupRef.Builder.class) +public final class SourceGroupRef { + private final String slug; + + private final String name; + + private final Optional description; + + private final Map additionalProperties; + + private SourceGroupRef( + String slug, String name, Optional description, Map additionalProperties) { + this.slug = slug; + this.name = name; + this.description = description; + this.additionalProperties = additionalProperties; + } + + /** + * @return Stable identifier for the source group. This is the value you pass in + * source_groups when creating a job. + */ + @JsonProperty("slug") + public String getSlug() { + return slug; + } + + /** + * @return Human-readable name of the source group. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return What the group covers, when set. + */ + @JsonIgnore + public Optional getDescription() { + if (description == null) { + return Optional.empty(); + } + return description; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("description") + private Optional _getDescription() { + return description; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SourceGroupRef && equalTo((SourceGroupRef) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SourceGroupRef other) { + return slug.equals(other.slug) && name.equals(other.name) && description.equals(other.description); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.slug, this.name, this.description); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SlugStage builder() { + return new Builder(); + } + + public interface SlugStage { + /** + *

        Stable identifier for the source group. This is the value you pass in + * source_groups when creating a job.

        + */ + NameStage slug(@NotNull String slug); + + Builder from(SourceGroupRef other); + } + + public interface NameStage { + /** + *

        Human-readable name of the source group.

        + */ + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + SourceGroupRef build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

        What the group covers, when set.

        + */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage description(Nullable description); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SlugStage, NameStage, _FinalStage { + private String slug; + + private String name; + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SourceGroupRef other) { + slug(other.getSlug()); + name(other.getName()); + description(other.getDescription()); + return this; + } + + /** + *

        Stable identifier for the source group. This is the value you pass in + * source_groups when creating a job.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("slug") + public NameStage slug(@NotNull String slug) { + this.slug = Objects.requireNonNull(slug, "slug must not be null"); + return this; + } + + /** + *

        Human-readable name of the source group.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

        What the group covers, when set.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(Nullable description) { + if (description.isNull()) { + this.description = null; + } else if (description.isEmpty()) { + this.description = Optional.empty(); + } else { + this.description = Optional.of(description.get()); + } + return this; + } + + /** + *

        What the group covers, when set.

        + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

        What the group covers, when set.

        + */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public SourceGroupRef build() { + return new SourceGroupRef(slug, name, description, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/UpdateMonitorResponseDto.java b/src/main/java/com/newscatcher/catchall/types/UpdateMonitorResponseDto.java index 4665597..c17385d 100644 --- a/src/main/java/com/newscatcher/catchall/types/UpdateMonitorResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/UpdateMonitorResponseDto.java @@ -32,7 +32,7 @@ private UpdateMonitorResponseDto(String monitorId, String status, MapMonitor identifier.

        + *

        Event monitor identifier.

        */ StatusStage monitorId(@NotNull String monitorId); @@ -119,7 +119,7 @@ public Builder from(UpdateMonitorResponseDto other) { } /** - *

        Monitor identifier.

        + *

        Event monitor identifier.

        * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/types/WebhookPayload.java b/src/main/java/com/newscatcher/catchall/types/WebhookPayload.java index 3779878..c63f1c9 100644 --- a/src/main/java/com/newscatcher/catchall/types/WebhookPayload.java +++ b/src/main/java/com/newscatcher/catchall/types/WebhookPayload.java @@ -66,7 +66,7 @@ private WebhookPayload( } /** - * @return Monitor identifier. + * @return Event monitor identifier. */ @JsonProperty("monitor_id") public Optional getMonitorId() { @@ -74,7 +74,7 @@ public Optional getMonitorId() { } /** - * @return Reference job used as template for this monitor. + * @return Reference job used as template for this event monitor. */ @JsonProperty("reference_job_id") public Optional getReferenceJobId() { @@ -98,7 +98,7 @@ public Optional getRecordsCount() { } /** - * @return Total number of jobs executed by this monitor. + * @return Total number of jobs executed by this event monitor. */ @JsonProperty("jobs_processed") public Optional getJobsProcessed() { @@ -114,7 +114,7 @@ public Optional getUpdatedAt() { } /** - * @return Cron expression defining the monitor schedule. + * @return Cron expression defining the event monitor schedule. */ @JsonProperty("cron_expression") public Optional getCronExpression() { @@ -130,7 +130,7 @@ public Optional getTimezone() { } /** - * @return Array of new records from the latest job execution (includes monitor-specific fields like added_on, updated_on). + * @return Array of new records from the latest job execution (includes event monitor-specific fields like added_on, updated_on). */ @JsonProperty("records") public Optional> getRecords() { @@ -222,7 +222,7 @@ public Builder from(WebhookPayload other) { } /** - *

        Monitor identifier.

        + *

        Event monitor identifier.

        */ @JsonSetter(value = "monitor_id", nulls = Nulls.SKIP) public Builder monitorId(Optional monitorId) { @@ -236,7 +236,7 @@ public Builder monitorId(String monitorId) { } /** - *

        Reference job used as template for this monitor.

        + *

        Reference job used as template for this event monitor.

        */ @JsonSetter(value = "reference_job_id", nulls = Nulls.SKIP) public Builder referenceJobId(Optional referenceJobId) { @@ -278,7 +278,7 @@ public Builder recordsCount(Integer recordsCount) { } /** - *

        Total number of jobs executed by this monitor.

        + *

        Total number of jobs executed by this event monitor.

        */ @JsonSetter(value = "jobs_processed", nulls = Nulls.SKIP) public Builder jobsProcessed(Optional jobsProcessed) { @@ -306,7 +306,7 @@ public Builder updatedAt(OffsetDateTime updatedAt) { } /** - *

        Cron expression defining the monitor schedule.

        + *

        Cron expression defining the event monitor schedule.

        */ @JsonSetter(value = "cron_expression", nulls = Nulls.SKIP) public Builder cronExpression(Optional cronExpression) { @@ -334,7 +334,7 @@ public Builder timezone(String timezone) { } /** - *

        Array of new records from the latest job execution (includes monitor-specific fields like added_on, updated_on).

        + *

        Array of new records from the latest job execution (includes event monitor-specific fields like added_on, updated_on).

        */ @JsonSetter(value = "records", nulls = Nulls.SKIP) public Builder records(Optional> records) {