From 35c40a78728079071895841f2a41d8c06b24e666 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 29 May 2026 12:58:08 +0000 Subject: [PATCH] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-java-sdk: 4.8.11 --- .fern/metadata.json | 13 +- .fern/replay.lock | 10 + .fernignore | 5 +- .gitattributes | 1 + README.md | 5 +- build.gradle | 4 +- reference.md | 2505 ++++++++++++++--- .../catchall/AsyncCatchAllApi.java | 16 + .../com/newscatcher/catchall/CatchAllApi.java | 16 + .../catchall/core/ClientOptions.java | 4 +- .../datasets/AsyncRawDatasetsClient.java | 4 + .../resources/datasets/RawDatasetsClient.java | 4 + .../requests/ListDatasetsRequest.java | 51 +- .../resources/jobs/AsyncJobsClient.java | 19 + .../resources/jobs/AsyncRawJobsClient.java | 93 + .../catchall/resources/jobs/JobsClient.java | 18 + .../resources/jobs/RawJobsClient.java | 75 + .../jobs/requests/GetUserJobsRequest.java | 36 +- .../jobs/requests/SubmitRequestDto.java | 94 +- .../requests/ValidateQueryRequestDto.java | 129 + .../monitors/AsyncRawMonitorsClient.java | 4 + .../resources/monitors/RawMonitorsClient.java | 4 + .../requests/CreateMonitorRequestDto.java | 110 +- .../requests/ListMonitorsRequest.java | 36 +- .../requests/UpdateMonitorRequestDto.java | 40 +- .../types/DisableMonitorResponse.java | 8 +- .../monitors/types/EnableMonitorResponse.java | 8 +- .../projects/AsyncProjectsClient.java | 315 +++ .../projects/AsyncRawProjectsClient.java | 964 +++++++ .../resources/projects/ProjectsClient.java | 304 ++ .../resources/projects/RawProjectsClient.java | 789 ++++++ .../requests/AddResourceRequestDto.java | 123 + .../requests/CreateProjectRequestDto.java | 173 ++ .../requests/DeleteProjectRequest.java | 111 + .../requests/GetProjectOverviewRequest.java | 69 + .../projects/requests/GetProjectRequest.java | 69 + .../requests/ListProjectResourcesRequest.java | 166 ++ .../requests/ListProjectsRequest.java | 198 ++ .../RemoveResourceFromProjectRequest.java | 69 + .../requests/UpdateProjectRequestDto.java | 140 + .../webhooks/AsyncRawWebhooksClient.java | 1209 ++++++++ .../webhooks/AsyncWebhooksClient.java | 382 +++ .../resources/webhooks/RawWebhooksClient.java | 990 +++++++ .../resources/webhooks/WebhooksClient.java | 372 +++ .../AssignWebhookResourceRequestDto.java | 164 ++ .../requests/CreateWebhookRequestDto.java | 535 ++++ .../requests/DeleteWebhookRequest.java | 69 + .../GetWebhookDeliveryHistoryRequest.java | 255 ++ .../webhooks/requests/GetWebhookRequest.java | 69 + .../requests/ListWebhookResourcesRequest.java | 166 ++ .../ListWebhooksForResourceRequest.java | 171 ++ .../requests/ListWebhooksRequest.java | 171 ++ .../RemoveWebhookResourceRequest.java | 69 + .../requests/TestWebhookRequestDto.java | 113 + .../requests/UpdateWebhookRequestDto.java | 413 +++ .../types/CreateWebhookRequestDtoAuth.java | 286 ++ .../types/UpdateWebhookRequestDtoAuth.java | 286 ++ .../types/AddResourceResponseDto.java | 227 ++ .../catchall/types/ApiKeyAuthDto.java | 162 ++ .../AssignWebhookResourceResponseDto.java | 262 ++ .../catchall/types/BasicAuthDto.java | 162 ++ .../catchall/types/BearerAuthDto.java | 129 + .../catchall/types/ConnectedEntity.java | 8 +- .../types/CreateProjectResponseDto.java | 232 ++ .../types/CreateWebhookResponseDto.java | 209 ++ .../catchall/types/DeleteJobResponseDto.java | 8 +- .../types/DeleteMonitorResponseDto.java | 8 +- .../types/DeliveryHistoryItemDto.java | 597 ++++ .../types/DeliveryHistoryResponseDto.java | 378 +++ .../catchall/types/DeliveryMode.java | 82 + .../catchall/types/DeliveryStatus.java | 83 + .../catchall/types/GetWebhookResponseDto.java | 209 ++ .../catchall/types/HttpMethod.java | 112 + .../newscatcher/catchall/types/IssueType.java | 153 + .../newscatcher/catchall/types/JobStep.java | 8 +- .../ListWebhookResourcesResponseDto.java | 299 ++ .../types/ListWebhooksResponseDto.java | 298 ++ .../catchall/types/MappableResourceType.java | 94 + .../catchall/types/MonitorListItemDto.java | 8 +- .../MonitorStatusHistoryResponseDto.java | 8 +- .../types/ProjectListResponseDto.java | 298 ++ .../types/ProjectOverviewResponseDto.java | 163 ++ .../ProjectOverviewResponseDtoOverview.java | 221 ++ .../catchall/types/ProjectResourceDto.java | 291 ++ .../types/ProjectResourceListResponseDto.java | 299 ++ .../catchall/types/ProjectResourceType.java | 104 + .../catchall/types/ProjectResponseDto.java | 458 +++ .../catchall/types/ProjectSummaryDto.java | 373 +++ .../catchall/types/QueryStatus.java | 92 + .../types/RemoveResourceResponseDto.java | 162 ++ .../catchall/types/ResourceItemDto.java | 152 + .../catchall/types/ResourceResultDto.java | 283 ++ .../catchall/types/Suggestion.java | 206 ++ .../types/TestWebhookResponseDto.java | 254 ++ .../types/UpdateProjectResponseDto.java | 196 ++ .../types/UpdateWebhookResponseDto.java | 209 ++ .../types/ValidateQueryResponseDto.java | 334 +++ .../WebhookResourceMappingResponseDto.java | 284 ++ .../catchall/types/WebhookResponseDto.java | 679 +++++ .../catchall/types/WebhookType.java | 102 + 100 files changed, 20933 insertions(+), 485 deletions(-) create mode 100644 .fern/replay.lock create mode 100644 .gitattributes create mode 100644 src/main/java/com/newscatcher/catchall/resources/jobs/requests/ValidateQueryRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/AsyncProjectsClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/ProjectsClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/AddResourceRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/CreateProjectRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectOverviewRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectResourcesRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectsRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/RemoveResourceFromProjectRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/projects/requests/UpdateProjectRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/AssignWebhookResourceRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/CreateWebhookRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/DeleteWebhookRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookDeliveryHistoryRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhookResourcesRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksForResourceRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/RemoveWebhookResourceRequest.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/TestWebhookRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/requests/UpdateWebhookRequestDto.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/types/CreateWebhookRequestDtoAuth.java create mode 100644 src/main/java/com/newscatcher/catchall/resources/webhooks/types/UpdateWebhookRequestDtoAuth.java create mode 100644 src/main/java/com/newscatcher/catchall/types/AddResourceResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ApiKeyAuthDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/AssignWebhookResourceResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/BasicAuthDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/BearerAuthDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/CreateProjectResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/CreateWebhookResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/DeliveryHistoryResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/DeliveryMode.java create mode 100644 src/main/java/com/newscatcher/catchall/types/DeliveryStatus.java create mode 100644 src/main/java/com/newscatcher/catchall/types/GetWebhookResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/HttpMethod.java create mode 100644 src/main/java/com/newscatcher/catchall/types/IssueType.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ListWebhookResourcesResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ListWebhooksResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/MappableResourceType.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectListResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDtoOverview.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectResourceDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectResourceListResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectResourceType.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ProjectSummaryDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/QueryStatus.java create mode 100644 src/main/java/com/newscatcher/catchall/types/RemoveResourceResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ResourceItemDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ResourceResultDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/Suggestion.java create mode 100644 src/main/java/com/newscatcher/catchall/types/TestWebhookResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/UpdateProjectResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/UpdateWebhookResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/ValidateQueryResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/WebhookResourceMappingResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/WebhookResponseDto.java create mode 100644 src/main/java/com/newscatcher/catchall/types/WebhookType.java diff --git a/.fern/metadata.json b/.fern/metadata.json index bc20bf3..61cfdde 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,16 +1,15 @@ { - "cliVersion": "5.28.2", + "cliVersion": "5.38.0", "generatorName": "fernapi/fern-java-sdk", - "generatorVersion": "4.8.10", + "generatorVersion": "4.8.11", "generatorConfig": { "publish-to": "central", "client-class-name": "CatchAllApi", "package-prefix": "com.newscatcher.catchall" }, - "originGitCommit": "22c183ea79ae5db44081d7400064d8907991d81b", + "originGitCommit": "5c18e5b13a9cc97f8ccdc7b91a6cd7b6f13ad6f4", "originGitCommitIsDirty": true, - "invokedBy": "ci", - "requestedVersion": "AUTO", - "ciProvider": "unknown", - "sdkVersion": "2.0.0" + "invokedBy": "manual", + "requestedVersion": "3.0.0", + "sdkVersion": "3.0.0" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock new file mode 100644 index 0000000..ab10719 --- /dev/null +++ b/.fern/replay.lock @@ -0,0 +1,10 @@ +# DO NOT EDIT MANUALLY - Managed by Fern Replay +version: "1.0" +generations: + - commit_sha: 4bf57ec2b0c2b8d170a06ccc5b084eb9ca3fba55 + tree_hash: d017d4bba4d9e4c062be5d92eedc787f121205ed + timestamp: 2026-05-29T12:58:06.809Z + cli_version: unknown + generator_versions: {} +current_generation: 4bf57ec2b0c2b8d170a06ccc5b084eb9ca3fba55 +patches: [] diff --git a/.fernignore b/.fernignore index 3a27c52..3b3ae09 100644 --- a/.fernignore +++ b/.fernignore @@ -5,4 +5,7 @@ gradlew.bat changelog.md # CI -.github/workflows/sdk-release.yml \ No newline at end of file +.github/workflows/sdk-release.yml +.fern/replay.lock +.fern/replay.yml +.gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..74928d6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.fern/replay.lock linguist-generated=true diff --git a/README.md b/README.md index 35e89ab..6eff517 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:2.0.0' + implementation 'com.newscatcherapi:newscatcher-catchall-sdk:3.0.0' } ``` @@ -47,7 +47,7 @@ Add the dependency in your `pom.xml` file: com.newscatcherapi newscatcher-catchall-sdk - 2.0.0 + 3.0.0 ``` @@ -262,3 +262,4 @@ On the other hand, contributions to the README are always very welcome! + diff --git a/build.gradle b/build.gradle index be9efdc..275971a 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'com.newscatcherapi' -version = '2.0.0' +version = '3.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'com.newscatcherapi' artifactId = 'newscatcher-catchall-sdk' - version = '2.0.0' + version = '3.0.0' from components.java pom { name = 'newscatcher' diff --git a/reference.md b/reference.md index 79f86eb..d51582c 100644 --- a/reference.md +++ b/reference.md @@ -30,6 +30,7 @@ Returns all jobs created by the authenticated user. client.jobs().getUserJobs( GetUserJobsRequest .builder() + .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") .build() ); ``` @@ -72,6 +73,75 @@ client.jobs().getUserJobs( **ownership:** `Optional` + + + +
+
+ +**projectId:** `Optional` — Filter results to resources belonging to this project. + +
+
+ + + + + + + + +
client.jobs.validateQuery(request) -> ValidateQueryResponseDto +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Checks whether a query is well-formed and likely to produce good results before submitting a job. + +Returns a quality assessment with a status level, identified issues, and actionable suggestions. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.jobs().validateQuery( + ValidateQueryRequestDto + .builder() + .query("Series B funding rounds for SaaS startups") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**query:** `String` — Plain text query to validate. +
@@ -297,6 +367,22 @@ The minimum relevance score a connected entity must reach for its record to be i Only valid when `connected_dataset_ids` is set; otherwise ignored. Records where no connected entity meets the threshold are excluded entirely. +
+
+ +
+
+ +**projectId:** `Optional` — Project to assign this job to. The job appears in the project's resource list immediately after submission. + +
+
+ +
+
+ +**webhookIds:** `Optional>` — IDs of webhooks to notify when the job completes. Maximum 5 per job. +
@@ -603,6 +689,7 @@ Returns all monitors created by the authenticated user. client.monitors().listMonitors( ListMonitorsRequest .builder() + .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") .build() ); ``` @@ -645,6 +732,14 @@ client.monitors().listMonitors( **ownership:** `Optional` + + + +
+
+ +**projectId:** `Optional` — Filter results to resources belonging to this project. +
@@ -688,17 +783,10 @@ client.monitors().createMonitor( .referenceJobId("5f0c9087-85cb-4917-b3c7-e5a5eff73a0c") .schedule("every day at 12 PM") .timezone("UTC") - .webhook( - WebhookDto - .builder() - .url("https://your-endpoint.com/webhook") - .method(WebhookDtoMethod.POST) - .headers( - new HashMap() {{ - put("Authorization", "Bearer your_token_here"); - }} - ) - .build() + .webhookIds( + Optional.of( + Arrays.asList("a1b2c3d4-e5f6-7890-abcd-ef1234567890") + ) ) .limit(10) .backfill(true) @@ -750,7 +838,12 @@ If the schedule includes a timezone abbreviation (for example, `"every day at 9a
-**webhook:** `Optional` — Optional webhook to receive notifications when jobs complete. +**webhookIds:** `Optional>` + +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.
@@ -772,6 +865,14 @@ If true, fills the data gap between the reference job's `end_date` and the first If false, no gap filling occurs and the first run uses the current cron window only — the reference job's age does not matter. + + + +
+
+ +**projectId:** `Optional` — Project to assign this monitor to. The monitor appears in the project's resource list after creation. +
@@ -1195,17 +1296,10 @@ client.monitors().updateMonitor( "monitor_id", UpdateMonitorRequestDto .builder() - .webhook( - WebhookDto - .builder() - .url("https://new-endpoint.com/webhook") - .method(WebhookDtoMethod.POST) - .headers( - new HashMap() {{ - put("Authorization", "Bearer new_token_xyz"); - }} - ) - .build() + .webhookIds( + Optional.of( + Arrays.asList("a1b2c3d4-e5f6-7890-abcd-ef1234567890") + ) ) .build() ); @@ -1231,7 +1325,11 @@ client.monitors().updateMonitor(
-**webhook:** `Optional` — Updated webhook configuration. +**webhookIds:** `Optional>` + +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.
@@ -1251,8 +1349,8 @@ client.monitors().updateMonitor(
-## Entities -
client.entities.listEntities() -> EntityListResponse +## Webhooks +
client.webhooks.listWebhooks() -> ListWebhooksResponseDto
@@ -1264,7 +1362,7 @@ client.monitors().updateMonitor(
-Returns a paginated list of entities belonging to the authenticated organization. Supports filtering by status and entity type, and sorting by name, status, or creation date. +Returns a paginated list of webhooks belonging to the organization.
@@ -1279,10 +1377,9 @@ Returns a paginated list of entities belonging to the authenticated organization
```java -client.entities().listEntities( - ListEntitiesRequest +client.webhooks().listWebhooks( + ListWebhooksRequest .builder() - .search("NewsCatcher") .build() ); ``` @@ -1307,7 +1404,7 @@ client.entities().listEntities(
-**pageSize:** `Optional` — Number of entities per page. +**pageSize:** `Optional` — Number of webhooks per page.
@@ -1315,15 +1412,69 @@ client.entities().listEntities(
-**search:** `Optional` — Filter entities by name (case-insensitive substring match). +**search:** `Optional` — Filter results by text (case-insensitive substring match).
+
+
+ + + + +
+
client.webhooks.createWebhook(request) -> CreateWebhookResponseDto
-**status:** `Optional` +#### 📝 Description + +
+
+ +
+
+ +Creates a new webhook endpoint for the organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().createWebhook( + CreateWebhookRequestDto + .builder() + .name("Layoffs Alert") + .url("https://hooks.slack.com/services/T000/B000/xxx") + .type(WebhookType.SLACK) + .deliveryMode(DeliveryMode.FULL) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `String` — Human-readable label for this webhook.
@@ -1331,7 +1482,17 @@ client.entities().listEntities(
-**entityType:** `Optional` +**url:** `String` + +Destination URL that receives the payload. Must use HTTPS. IP addresses are not accepted. + +Type-specific URL requirements: +- `slack`: Must start with `https://hooks.slack.com/`. +- `teams`: Hostname must match `*.webhook.office.com` or `*.webhook.office365.com`. +- `generic`: Any valid HTTPS domain. +- `custom`: Any valid HTTPS domain. + +When `type` is omitted, it is auto-detected from the URL.
@@ -1339,7 +1500,7 @@ client.entities().listEntities(
-**sortBy:** `Optional` +**type:** `Optional`
@@ -1347,7 +1508,52 @@ client.entities().listEntities(
-**sortOrder:** `Optional` +**deliveryMode:** `Optional` + +
+
+ +
+
+ +**method:** `Optional` + +
+
+ +
+
+ +**headers:** `Optional>` — Custom HTTP headers forwarded with each delivery. + +
+
+ +
+
+ +**params:** `Optional>` — Query parameters appended to the webhook URL. + +
+
+ +
+
+ +**auth:** `Optional` + +Authentication forwarded with each delivery. Supported types: +- `bearer`: Adds an `Authorization: Bearer ` header. +- `api_key`: Adds a custom header with the specified name and value. +- `basic`: Adds an `Authorization: Basic ` header. + +
+
+ +
+
+ +**formatterConfig:** `Optional>` — Custom payload transformation configuration. Required only when `type` is `custom`.
@@ -1359,7 +1565,7 @@ client.entities().listEntities(
-
client.entities.createEntity(request) -> CreateEntityResponse +
client.webhooks.getWebhook(webhookId) -> GetWebhookResponseDto
@@ -1371,12 +1577,7 @@ client.entities().listEntities(
-Creates a new company entity and begins background enrichment. - -The entity status starts as `pending` and transitions to `ready` once -enrichment completes. Provide as much identifying information as -possible — `domain` is the highest-signal field because it is -unambiguous. +Returns the full configuration of a single webhook by ID.
@@ -1391,33 +1592,10 @@ unambiguous.
```java -client.entities().createEntity( - CreateEntityRequest +client.webhooks().getWebhook( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + GetWebhookRequest .builder() - .name("NewsCatcher") - .entityType(EntityType.COMPANY) - .description("AI-powered news data provider") - .additionalAttributes( - AdditionalAttributes - .builder() - .companyAttributes( - CompanyAttributes - .builder() - .domain("newscatcherapi.com") - .keyPersons( - Optional.of( - Arrays.asList("Artem Bugara", "Maksym Sugonyaka") - ) - ) - .alternativeNames( - Optional.of( - Arrays.asList("NC", "NewsCatcher API") - ) - ) - .build() - ) - .build() - ) .build() ); ``` @@ -1434,7 +1612,7 @@ client.entities().createEntity(
-**request:** `CreateEntityRequest` +**webhookId:** `String` — Unique webhook identifier.
@@ -1446,7 +1624,7 @@ client.entities().createEntity(
-
client.entities.createEntitiesBatch(request) -> CreateEntitiesBatchResponse +
client.webhooks.deleteWebhook(webhookId)
@@ -1458,9 +1636,9 @@ client.entities().createEntity(
-Creates multiple entities in a single request. Each entity is processed independently — a failure in one does not affect others. +Permanently deletes a webhook and removes all resource assignments. -Returns an array of `{id, status}` objects in the same order as the input array. +Assigned jobs and monitors no longer trigger delivery to this webhook. This operation cannot be undone.
@@ -1475,62 +1653,10 @@ Returns an array of `{id, status}` objects in the same order as the input array.
```java -client.entities().createEntitiesBatch( - CreateEntitiesBatchRequest +client.webhooks().deleteWebhook( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + DeleteWebhookRequest .builder() - .entities( - Arrays.asList( - CreateEntityRequest - .builder() - .name("OpenAI") - .entityType(EntityType.COMPANY) - .description("Artificial intelligence research company") - .additionalAttributes( - AdditionalAttributes - .builder() - .companyAttributes( - CompanyAttributes - .builder() - .domain("openai.com") - .keyPersons( - Optional.of( - Arrays.asList("Sam Altman") - ) - ) - .alternativeNames( - Optional.of( - Arrays.asList("Open AI") - ) - ) - .build() - ) - .build() - ) - .build(), - CreateEntityRequest - .builder() - .name("Stripe") - .entityType(EntityType.COMPANY) - .description("Online payment processing platform") - .additionalAttributes( - AdditionalAttributes - .builder() - .companyAttributes( - CompanyAttributes - .builder() - .domain("stripe.com") - .keyPersons( - Optional.of( - Arrays.asList("Patrick Collison", "John Collison") - ) - ) - .build() - ) - .build() - ) - .build() - ) - ) .build() ); ``` @@ -1547,10 +1673,7 @@ client.entities().createEntitiesBatch(
-**entities:** `List` - -Array of entities to create. Each item follows the same schema -as single entity creation. +**webhookId:** `String` — Unique webhook identifier.
@@ -1562,7 +1685,7 @@ as single entity creation.
-
client.entities.getEntity(entityId) -> EntityResponse +
client.webhooks.updateWebhook(webhookId, request) -> UpdateWebhookResponseDto
@@ -1574,7 +1697,7 @@ as single entity creation.
-Returns a single entity by ID with all attributes and current status. +Updates one or more fields of an existing webhook.
@@ -1589,10 +1712,12 @@ Returns a single entity by ID with all attributes and current status.
```java -client.entities().getEntity( - "854198fa-f702-49db-a381-0427fa87f173", - GetEntityRequest +client.webhooks().updateWebhook( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + UpdateWebhookRequestDto .builder() + .name("Layoffs Alert (EU)") + .isActive(false) .build() ); ``` @@ -1609,7 +1734,87 @@ client.entities().getEntity(
-**entityId:** `String` — Unique entity identifier. +**webhookId:** `String` — Unique webhook identifier. + +
+
+ +
+
+ +**name:** `Optional` — Updated webhook name. + +
+
+ +
+
+ +**url:** `Optional` — Updated destination URL. Must use HTTPS. Type-specific URL rules apply. + +
+
+ +
+
+ +**type:** `Optional` + +
+
+ +
+
+ +**deliveryMode:** `Optional` + +
+
+ +
+
+ +**method:** `Optional` + +
+
+ +
+
+ +**headers:** `Optional>` — Updated HTTP headers. Replaces existing headers entirely. + +
+
+ +
+
+ +**params:** `Optional>` — Updated query parameters. Replaces existing params entirely. + +
+
+ +
+
+ +**auth:** `Optional` — Updated authentication configuration. Replaces existing auth entirely. + +
+
+ +
+
+ +**formatterConfig:** `Optional>` — Updated formatter configuration. + +
+
+ +
+
+ +**isActive:** `Optional` — Set to `false` to disable delivery without deleting the webhook.
@@ -1621,7 +1826,7 @@ client.entities().getEntity(
-
client.entities.deleteEntity(entityId) +
client.webhooks.testWebhook(webhookId, request) -> TestWebhookResponseDto
@@ -1633,8 +1838,9 @@ client.entities().getEntity(
-Permanently deletes an entity. The entity is removed from all -datasets and the search index. This operation cannot be undone. +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.
@@ -1649,10 +1855,16 @@ datasets and the search index. This operation cannot be undone.
```java -client.entities().deleteEntity( - "854198fa-f702-49db-a381-0427fa87f173", - DeleteEntityRequest +client.webhooks().testWebhook( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + TestWebhookRequestDto .builder() + .payload( + new HashMap() {{ + put("test", true); + put("message", "CatchAll webhook test"); + }} + ) .build() ); ``` @@ -1669,7 +1881,18 @@ client.entities().deleteEntity(
-**entityId:** `String` — Unique entity identifier. +**webhookId:** `String` — Unique webhook identifier. + +
+
+ +
+
+ +**payload:** `Optional>` + +Custom payload to send in the test request. If omitted, a synthetic +test payload is sent.
@@ -1681,7 +1904,7 @@ client.entities().deleteEntity(
-
client.entities.updateEntity(entityId, request) -> EntityResponse +
client.webhooks.listWebhookResources(webhookId) -> ListWebhookResourcesResponseDto
@@ -1693,7 +1916,7 @@ client.entities().deleteEntity(
-Updates one or more fields of an existing entity. +Returns a paginated list of resources currently assigned to this webhook.
@@ -1708,26 +1931,10 @@ Updates one or more fields of an existing entity.
```java -client.entities().updateEntity( - "854198fa-f702-49db-a381-0427fa87f173", - UpdateEntityRequest +client.webhooks().listWebhookResources( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + ListWebhookResourcesRequest .builder() - .description("Updated description") - .additionalAttributes( - AdditionalAttributes - .builder() - .companyAttributes( - CompanyAttributes - .builder() - .alternativeNames( - Optional.of( - Arrays.asList("NC", "NewsCatcher API", "NCA") - ) - ) - .build() - ) - .build() - ) .build() ); ``` @@ -1744,7 +1951,7 @@ client.entities().updateEntity(
-**entityId:** `String` — Unique entity identifier. +**webhookId:** `String` — Unique webhook identifier.
@@ -1752,7 +1959,7 @@ client.entities().updateEntity(
-**name:** `Optional` — Updated entity name. +**resourceType:** `Optional`
@@ -1760,7 +1967,7 @@ client.entities().updateEntity(
-**description:** `Optional` — Updated description. +**page:** `Optional` — Page number to retrieve.
@@ -1768,7 +1975,7 @@ client.entities().updateEntity(
-**additionalAttributes:** `Optional` +**pageSize:** `Optional` — Number of assignments per page.
@@ -1780,8 +1987,7 @@ client.entities().updateEntity(
-## Datasets -
client.datasets.listDatasets() -> DatasetListResponse +
client.webhooks.assignWebhookResource(webhookId, request) -> AssignWebhookResourceResponseDto
@@ -1793,7 +1999,11 @@ client.entities().updateEntity(
-Returns a paginated list of datasets belonging to the authenticated organization. Supports filtering by status and sorting by name, status, or creation date. +Attaches a job, monitor, or 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.
@@ -1808,10 +2018,12 @@ Returns a paginated list of datasets belonging to the authenticated organization
```java -client.datasets().listDatasets( - ListDatasetsRequest +client.webhooks().assignWebhookResource( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + AssignWebhookResourceRequestDto .builder() - .search("Portfolio") + .resourceType(MappableResourceType.MONITOR) + .resourceId("3fec5b07-8786-46d7-9486-d43ff67eccd4") .build() ); ``` @@ -1828,7 +2040,7 @@ client.datasets().listDatasets(
-**page:** `Optional` — Page number to retrieve. +**webhookId:** `String` — Unique webhook identifier.
@@ -1836,7 +2048,7 @@ client.datasets().listDatasets(
-**pageSize:** `Optional` — Number of datasets per page. +**resourceType:** `MappableResourceType` — Type of resource to assign.
@@ -1844,15 +2056,70 @@ client.datasets().listDatasets(
-**search:** `Optional` — Filter datasets by name (case-insensitive substring match). +**resourceId:** `String` — ID of the resource to assign.
+
+
+ + + + +
+
client.webhooks.removeWebhookResource(webhookId, resourceType, resourceId)
-**latestStatus:** `Optional` — Filter by dataset status. +#### 📝 Description + +
+
+ +
+
+ +Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + +The webhook and the resource itself are not deleted. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().removeWebhookResource( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + MappableResourceType.JOB, + "3fec5b07-8786-46d7-9486-d43ff67eccd4", + RemoveWebhookResourceRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `String` — Unique webhook identifier.
@@ -1860,7 +2127,7 @@ client.datasets().listDatasets(
-**sortBy:** `Optional` +**resourceType:** `MappableResourceType`
@@ -1868,15 +2135,1565 @@ client.datasets().listDatasets(
-**sortOrder:** `Optional` +**resourceId:** `String` — Unique resource identifier.
+
+
+ + +
+
+
+ +
client.webhooks.listWebhooksForResource(resourceType, resourceId) -> ListWebhooksResponseDto +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns all webhooks currently assigned to the given resource. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().listWebhooksForResource( + MappableResourceType.JOB, + "3fec5b07-8786-46d7-9486-d43ff67eccd4", + ListWebhooksForResourceRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**resourceType:** `MappableResourceType` + +
+
+ +
+
+ +**resourceId:** `String` — Unique resource identifier. + +
+
+ +
+
+ +**isActive:** `Optional` — Filter by active status. Omit to return webhooks regardless of status. + +
+
+ +
+
+ +**page:** `Optional` — Page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — Number of webhooks per page. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.getWebhookDeliveryHistory() -> DeliveryHistoryResponseDto +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated delivery log for a given resource, ordered by timestamp descending. + +Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.webhooks().getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest + .builder() + .resourceType(MappableResourceType.JOB) + .resourceId("3fec5b07-8786-46d7-9486-d43ff67eccd4") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**resourceType:** `MappableResourceType` — Type of the resource to retrieve delivery history for. + +
+
+ +
+
+ +**resourceId:** `String` — Identifier of the resource to retrieve delivery history for. + +
+
+ +
+
+ +**page:** `Optional` — Page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — Number of records per page. + +
+
+
+
+ + +
+
+
+ +## Entities +
client.entities.listEntities() -> EntityListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of entities belonging to the authenticated organization. Supports filtering by status and entity type, and sorting by name, status, or creation date. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().listEntities( + ListEntitiesRequest + .builder() + .search("NewsCatcher") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — Page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — Number of entities per page. + +
+
+ +
+
+ +**search:** `Optional` — Filter entities by name (case-insensitive substring match). + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**sortBy:** `Optional` + +
+
+ +
+
+ +**sortOrder:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.entities.createEntity(request) -> CreateEntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a new company entity and begins background enrichment. + +The entity status starts as `pending` and transitions to `ready` once +enrichment completes. Provide as much identifying information as +possible — `domain` is the highest-signal field because it is +unambiguous. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().createEntity( + CreateEntityRequest + .builder() + .name("NewsCatcher") + .entityType(EntityType.COMPANY) + .description("AI-powered news data provider") + .additionalAttributes( + AdditionalAttributes + .builder() + .companyAttributes( + CompanyAttributes + .builder() + .domain("newscatcherapi.com") + .keyPersons( + Optional.of( + Arrays.asList("Artem Bugara", "Maksym Sugonyaka") + ) + ) + .alternativeNames( + Optional.of( + Arrays.asList("NC", "NewsCatcher API") + ) + ) + .build() + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEntityRequest` + +
+
+
+
+ + +
+
+
+ +
client.entities.createEntitiesBatch(request) -> CreateEntitiesBatchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates multiple entities in a single request. Each entity is processed independently — a failure in one does not affect others. + +Returns an array of `{id, status}` objects in the same order as the input array. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().createEntitiesBatch( + CreateEntitiesBatchRequest + .builder() + .entities( + Arrays.asList( + CreateEntityRequest + .builder() + .name("OpenAI") + .entityType(EntityType.COMPANY) + .description("Artificial intelligence research company") + .additionalAttributes( + AdditionalAttributes + .builder() + .companyAttributes( + CompanyAttributes + .builder() + .domain("openai.com") + .keyPersons( + Optional.of( + Arrays.asList("Sam Altman") + ) + ) + .alternativeNames( + Optional.of( + Arrays.asList("Open AI") + ) + ) + .build() + ) + .build() + ) + .build(), + CreateEntityRequest + .builder() + .name("Stripe") + .entityType(EntityType.COMPANY) + .description("Online payment processing platform") + .additionalAttributes( + AdditionalAttributes + .builder() + .companyAttributes( + CompanyAttributes + .builder() + .domain("stripe.com") + .keyPersons( + Optional.of( + Arrays.asList("Patrick Collison", "John Collison") + ) + ) + .build() + ) + .build() + ) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entities:** `List` + +Array of entities to create. Each item follows the same schema +as single entity creation. + +
+
+
+
+ + +
+
+
+ +
client.entities.getEntity(entityId) -> EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a single entity by ID with all attributes and current status. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().getEntity( + "854198fa-f702-49db-a381-0427fa87f173", + GetEntityRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `String` — Unique entity identifier. + +
+
+
+
+ + +
+
+
+ +
client.entities.deleteEntity(entityId) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Permanently deletes an entity. The entity is removed from all +datasets and the search index. This operation cannot be undone. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().deleteEntity( + "854198fa-f702-49db-a381-0427fa87f173", + DeleteEntityRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `String` — Unique entity identifier. + +
+
+
+
+ + +
+
+
+ +
client.entities.updateEntity(entityId, request) -> EntityResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates one or more fields of an existing entity. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.entities().updateEntity( + "854198fa-f702-49db-a381-0427fa87f173", + UpdateEntityRequest + .builder() + .description("Updated description") + .additionalAttributes( + AdditionalAttributes + .builder() + .companyAttributes( + CompanyAttributes + .builder() + .alternativeNames( + Optional.of( + Arrays.asList("NC", "NewsCatcher API", "NCA") + ) + ) + .build() + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityId:** `String` — Unique entity identifier. + +
+
+ +
+
+ +**name:** `Optional` — Updated entity name. + +
+
+ +
+
+ +**description:** `Optional` — Updated description. + +
+
+ +
+
+ +**additionalAttributes:** `Optional` + +
+
+
+
+ + +
+
+
+ +## Datasets +
client.datasets.listDatasets() -> DatasetListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of datasets belonging to the authenticated organization. Supports filtering by status and sorting by name, status, or creation date. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().listDatasets( + ListDatasetsRequest + .builder() + .search("Portfolio") + .projectId("60a85db4-78ec-4b78-876a-bc7d9cdadd04") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — Page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — Number of datasets per page. + +
+
+ +
+
+ +**search:** `Optional` — Filter datasets by name (case-insensitive substring match). + +
+
+ +
+
+ +**latestStatus:** `Optional` — Filter by dataset status. + +
+
+ +
+
+ +**sortBy:** `Optional` + +
+
+ +
+
+ +**sortOrder:** `Optional` + +
+
+ +
+
+ +**ownership:** `Optional` + +
+
+ +
+
+ +**projectId:** `Optional` — Filter results to resources belonging to this project. + +
+
+
+
+ + +
+
+
+ +
client.datasets.createDataset(request) -> DatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a new dataset from a list of existing entity IDs. + +If any of the provided entity IDs do not exist or do not belong to +your organization, the request fails with `400`. All entity IDs must +be valid before the dataset is created. + +To create a dataset and entities in one step, use the [`Create dataset from CSV`](https://www.newscatcherapi.com/docs/web-search-api/api-reference/datasets/create-dataset-from-csv) +endpoint instead. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().createDataset( + CreateDatasetRequest + .builder() + .name("My Portfolio") + .description("Companies in our investment portfolio") + .entityIds( + Optional.of( + Arrays.asList("854198fa-f702-49db-a381-0427fa87f173", "a1b2c3d4-e5f6-7890-abcd-ef1234567890") + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `String` — Name for the dataset. + +
+
+ +
+
+ +**description:** `Optional` — Optional description. + +
+
+ +
+
+ +**entityIds:** `Optional>` — IDs of existing entities to include in the dataset. All IDs must belong to the authenticated organization. If any ID is invalid or not found, the request fails with `400`. + +
+
+
+
+ + +
+
+
+ +
client.datasets.createDatasetFromCsv(request) -> CreateDatasetCsvResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates a new dataset by uploading a CSV file. Each row in the CSV becomes an entity. The `name` and `domain`columns are required; all other columns are optional. + +**CSV format:** +```csv +name,description,domain,alternative_names,key_persons +NewsCatcher,"AI-powered news data provider",newscatcherapi.com,"NC;NewsCatcher API","Artem Bugara;Maksym Sugonyaka" +OpenAI,"Artificial intelligence research company",openai.com,"Open AI","Sam Altman" +``` + +Use semicolons (`;`) to separate multiple values in `alternative_names` and `key_persons`. Rows with empty `name` are skipped and reported in `validation_report`. + +**Note**: The response shape differs from the JSON dataset creation endpoint: it returns `dataset_id` (not `id`) and includes a `validation_report` with details on skipped rows. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().createDatasetFromCsv( + null, + CreateDatasetFromCsvRequest + .builder() + .name("name") + .build() +); +``` +
+
+
+
+ + +
+
+
+ +
client.datasets.getDataset(datasetId) -> DatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a single dataset by ID including entity count and current status. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().getDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + GetDatasetRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+
+
+ + +
+
+
+ +
client.datasets.deleteDataset(datasetId) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Permanently deletes a dataset. The entities within the dataset are +not deleted — only the dataset itself. This operation cannot be +undone. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().deleteDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + DeleteDatasetRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+
+
+ + +
+
+
+ +
client.datasets.updateDataset(datasetId, request) -> DatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Updates the name or description of a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().updateDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + UpdateDatasetRequest + .builder() + .name("My Portfolio (updated)") + .description("Updated Q1 2026 watchlist") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+ +
+
+ +**name:** `Optional` — Updated dataset name. + +
+
+ +
+
+ +**description:** `Optional` — Updated description. + +
+
+
+
+ + +
+
+
+ +
client.datasets.addEntitiesToDataset(datasetId, request) -> ManageEntitiesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Adds one or more existing entities to a dataset. Returns the number of entities added. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().addEntitiesToDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + AddEntitiesToDatasetRequest + .builder() + .body( + DatasetEntityIdsRequest + .builder() + .entityIds( + Arrays.asList("854198fa-f702-49db-a381-0427fa87f173") + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+ +
+
+ +**request:** `DatasetEntityIdsRequest` + +
+
+
+
+ + +
+
+
+ +
client.datasets.removeEntitiesFromDataset(datasetId, request) -> ManageEntitiesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Removes one or more entities from a dataset. The entities themselves are not deleted — they are only removed from this dataset. Returns the number of entities removed. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().removeEntitiesFromDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + RemoveEntitiesFromDatasetRequest + .builder() + .body( + DatasetEntityIdsRequest + .builder() + .entityIds( + Arrays.asList("854198fa-f702-49db-a381-0427fa87f173") + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+ +
+
+ +**request:** `DatasetEntityIdsRequest` + +
+
+
+
+ + +
+
+
+ +
client.datasets.listEntitiesInDataset(datasetId, request) -> DatasetEntityListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a paginated list of entities in a dataset. Supports filtering by status, entity type, and name search. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().listEntitiesInDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + ListDatasetEntitiesRequest + .builder() + .page(1) + .pageSize(100) + .search("OpenAI") + .status(EntityStatus.READY) + .entityType(EntityType.COMPANY) + .sortBy(EntitySortBy.CREATED_AT) + .sortOrder(SortOrder.DESC) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+ +
+
+ +**page:** `Optional` — The page number to retrieve. + +
+
+ +
+
+ +**pageSize:** `Optional` — The number of entities per page. + +
+
+ +
+
+ +**search:** `Optional` — Filters entities by name using a case-insensitive substring match. + +
+
+ +
+
+ +**status:** `Optional` + +
+
+ +
+
+ +**entityType:** `Optional` + +
+
+ +
+
+ +**sortBy:** `Optional` + +
+
+ +
+
+ +**sortOrder:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.datasets.getDatasetStatusHistory(datasetId) -> DatasetStatusHistoryResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the full status change history for a dataset, ordered chronologically from oldest to newest. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().getDatasetStatusHistory( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + GetDatasetStatusHistoryRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` — Unique dataset identifier. + +
+
+
+
+ + +
+
+
+ +
client.datasets.uploadCsvToDataset(datasetId, request) -> UploadCsvToDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Appends new companies to an existing dataset by uploading a CSV file. Uses the same CSV format as the dataset creation endpoint. + +The response omits `dataset_name` compared to the create-from-CSV endpoint since the dataset already exists. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.datasets().uploadCsvToDataset( + "ccabb755-afc2-4047-b84c-78d1f23d49b2", + null, + UploadCsvToDatasetRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters
-**ownership:** `Optional` +
+
+ +**datasetId:** `String` — Unique dataset identifier.
@@ -1888,7 +3705,8 @@ client.datasets().listDatasets(
-
client.datasets.createDataset(request) -> DatasetResponse +## Projects +
client.projects.listProjects() -> ProjectListResponseDto
@@ -1900,14 +3718,7 @@ client.datasets().listDatasets(
-Creates a new dataset from a list of existing entity IDs. - -If any of the provided entity IDs do not exist or do not belong to -your organization, the request fails with `400`. All entity IDs must -be valid before the dataset is created. - -To create a dataset and entities in one step, use the [`Create dataset from CSV`](https://www.newscatcherapi.com/docs/web-search-api/api-reference/datasets/create-dataset-from-csv) -endpoint instead. +Returns all projects visible to the authenticated user.
@@ -1922,16 +3733,10 @@ endpoint instead.
```java -client.datasets().createDataset( - CreateDatasetRequest +client.projects().listProjects( + ListProjectsRequest .builder() - .name("My Portfolio") - .description("Companies in our investment portfolio") - .entityIds( - Optional.of( - Arrays.asList("854198fa-f702-49db-a381-0427fa87f173", "a1b2c3d4-e5f6-7890-abcd-ef1234567890") - ) - ) + .search("M&A") .build() ); ``` @@ -1948,7 +3753,7 @@ client.datasets().createDataset(
-**name:** `String` — Name for the dataset. +**page:** `Optional` — Page number to retrieve.
@@ -1956,7 +3761,7 @@ client.datasets().createDataset(
-**description:** `Optional` — Optional description. +**pageSize:** `Optional` — Number of records per page.
@@ -1964,64 +3769,16 @@ client.datasets().createDataset(
-**entityIds:** `Optional>` — IDs of existing entities to include in the dataset. All IDs must belong to the authenticated organization. If any ID is invalid or not found, the request fails with `400`. +**search:** `Optional` — Filter by project name (case-insensitive substring match).
-
-
- - - - -
- -
client.datasets.createDatasetFromCsv(request) -> CreateDatasetCsvResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Creates a new dataset by uploading a CSV file. Each row in the CSV becomes an entity. The `name` and `domain`columns are required; all other columns are optional. - -**CSV format:** -```csv -name,description,domain,alternative_names,key_persons -NewsCatcher,"AI-powered news data provider",newscatcherapi.com,"NC;NewsCatcher API","Artem Bugara;Maksym Sugonyaka" -OpenAI,"Artificial intelligence research company",openai.com,"Open AI","Sam Altman" -``` - -Use semicolons (`;`) to separate multiple values in `alternative_names` and `key_persons`. Rows with empty `name` are skipped and reported in `validation_report`. - -**Note**: The response shape differs from the JSON dataset creation endpoint: it returns `dataset_id` (not `id`) and includes a `validation_report` with details on skipped rows. -
-
-
-
- -#### 🔌 Usage - -
-
-```java -client.datasets().createDatasetFromCsv( - null, - CreateDatasetFromCsvRequest - .builder() - .name("name") - .build() -); -``` +**ownership:** `Optional` +
@@ -2032,7 +3789,7 @@ client.datasets().createDatasetFromCsv(
-
client.datasets.getDataset(datasetId) -> DatasetResponse +
client.projects.createProject(request) -> CreateProjectResponseDto
@@ -2044,7 +3801,7 @@ client.datasets().createDatasetFromCsv(
-Returns a single dataset by ID including entity count and current status. +Creates a new project.
@@ -2059,10 +3816,11 @@ Returns a single dataset by ID including entity count and current status.
```java -client.datasets().getDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - GetDatasetRequest +client.projects().createProject( + CreateProjectRequestDto .builder() + .name("AI M&A Tracking") + .description("Tracks AI-related M&A activity for our investment team.") .build() ); ``` @@ -2079,7 +3837,15 @@ client.datasets().getDataset(
-**datasetId:** `String` — Unique dataset identifier. +**name:** `String` — Name for the project. + +
+
+ +
+
+ +**description:** `Optional` — Optional description.
@@ -2091,7 +3857,7 @@ client.datasets().getDataset(
-
client.datasets.deleteDataset(datasetId) +
client.projects.getProject(projectId) -> ProjectResponseDto
@@ -2103,9 +3869,7 @@ client.datasets().getDataset(
-Permanently deletes a dataset. The entities within the dataset are -not deleted — only the dataset itself. This operation cannot be -undone. +Returns a single project by ID.
@@ -2120,9 +3884,9 @@ undone.
```java -client.datasets().deleteDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - DeleteDatasetRequest +client.projects().getProject( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + GetProjectRequest .builder() .build() ); @@ -2140,7 +3904,7 @@ client.datasets().deleteDataset(
-**datasetId:** `String` — Unique dataset identifier. +**projectId:** `String` — Unique project identifier.
@@ -2152,7 +3916,7 @@ client.datasets().deleteDataset(
-
client.datasets.updateDataset(datasetId, request) -> DatasetResponse +
client.projects.deleteProject(projectId)
@@ -2164,7 +3928,7 @@ client.datasets().deleteDataset(
-Updates the name or description of a dataset. +Deletes a project. By default, assigned resources are unassigned but not deleted.
@@ -2179,12 +3943,10 @@ Updates the name or description of a dataset.
```java -client.datasets().updateDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - UpdateDatasetRequest +client.projects().deleteProject( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + DeleteProjectRequest .builder() - .name("My Portfolio (updated)") - .description("Updated Q1 2026 watchlist") .build() ); ``` @@ -2201,15 +3963,7 @@ client.datasets().updateDataset(
-**datasetId:** `String` — Unique dataset identifier. - -
-
- -
-
- -**name:** `Optional` — Updated dataset name. +**projectId:** `String` — Unique project identifier.
@@ -2217,7 +3971,7 @@ client.datasets().updateDataset(
-**description:** `Optional` — Updated description. +**deleteResources:** `Optional` — If true, permanently deletes all resources (jobs, monitors, datasets) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted.
@@ -2229,7 +3983,7 @@ client.datasets().updateDataset(
-
client.datasets.addEntitiesToDataset(datasetId, request) -> ManageEntitiesResponse +
client.projects.updateProject(projectId, request) -> UpdateProjectResponseDto
@@ -2241,7 +3995,7 @@ client.datasets().updateDataset(
-Adds one or more existing entities to a dataset. Returns the number of entities added. +Updates the name or description of an existing project.
@@ -2256,18 +4010,11 @@ Adds one or more existing entities to a dataset. Returns the number of entities
```java -client.datasets().addEntitiesToDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - AddEntitiesToDatasetRequest +client.projects().updateProject( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + UpdateProjectRequestDto .builder() - .body( - DatasetEntityIdsRequest - .builder() - .entityIds( - Arrays.asList("854198fa-f702-49db-a381-0427fa87f173") - ) - .build() - ) + .name("AI M&A Tracking (Q2 2026)") .build() ); ``` @@ -2284,7 +4031,7 @@ client.datasets().addEntitiesToDataset(
-**datasetId:** `String` — Unique dataset identifier. +**projectId:** `String` — Unique project identifier.
@@ -2292,7 +4039,15 @@ client.datasets().addEntitiesToDataset(
-**request:** `DatasetEntityIdsRequest` +**name:** `Optional` — New name for the project. + +
+
+ +
+
+ +**description:** `Optional` — New description for the project.
@@ -2304,7 +4059,7 @@ client.datasets().addEntitiesToDataset(
-
client.datasets.removeEntitiesFromDataset(datasetId, request) -> ManageEntitiesResponse +
client.projects.getProjectOverview(projectId) -> ProjectOverviewResponseDto
@@ -2316,7 +4071,9 @@ client.datasets().addEntitiesToDataset(
-Removes one or more entities from a dataset. The entities themselves are not deleted — they are only removed from this dataset. Returns the number of entities removed. +Returns resource counts for a project, grouped by type and status. + +For `jobs` and `monitors`, counts are broken down by status (for example, `completed`, `failed`). For `datasets` and `monitor_groups`, only a `total` count is returned.
@@ -2331,18 +4088,10 @@ Removes one or more entities from a dataset. The entities themselves are not del
```java -client.datasets().removeEntitiesFromDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - RemoveEntitiesFromDatasetRequest +client.projects().getProjectOverview( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + GetProjectOverviewRequest .builder() - .body( - DatasetEntityIdsRequest - .builder() - .entityIds( - Arrays.asList("854198fa-f702-49db-a381-0427fa87f173") - ) - .build() - ) .build() ); ``` @@ -2359,15 +4108,7 @@ client.datasets().removeEntitiesFromDataset(
-**datasetId:** `String` — Unique dataset identifier. - -
-
- -
-
- -**request:** `DatasetEntityIdsRequest` +**projectId:** `String` — Unique project identifier.
@@ -2379,7 +4120,7 @@ client.datasets().removeEntitiesFromDataset(
-
client.datasets.listEntitiesInDataset(datasetId, request) -> DatasetEntityListResponse +
client.projects.listProjectResources(projectId) -> ProjectResourceListResponseDto
@@ -2391,7 +4132,7 @@ client.datasets().removeEntitiesFromDataset(
-Returns a paginated list of entities in a dataset. Supports filtering by status, entity type, and name search. +Returns all resources assigned to a project, with optional filtering by type.
@@ -2406,17 +4147,10 @@ Returns a paginated list of entities in a dataset. Supports filtering by status,
```java -client.datasets().listEntitiesInDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - ListDatasetEntitiesRequest +client.projects().listProjectResources( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + ListProjectResourcesRequest .builder() - .page(1) - .pageSize(100) - .search("OpenAI") - .status(EntityStatus.READY) - .entityType(EntityType.COMPANY) - .sortBy(EntitySortBy.CREATED_AT) - .sortOrder(SortOrder.DESC) .build() ); ``` @@ -2433,39 +4167,7 @@ client.datasets().listEntitiesInDataset(
-**datasetId:** `String` — Unique dataset identifier. - -
-
- -
-
- -**page:** `Optional` — The page number to retrieve. - -
-
- -
-
- -**pageSize:** `Optional` — The number of entities per page. - -
-
- -
-
- -**search:** `Optional` — Filters entities by name using a case-insensitive substring match. - -
-
- -
-
- -**status:** `Optional` +**projectId:** `String` — Unique project identifier.
@@ -2473,7 +4175,7 @@ client.datasets().listEntitiesInDataset(
-**entityType:** `Optional` +**resourceType:** `Optional`
@@ -2481,7 +4183,7 @@ client.datasets().listEntitiesInDataset(
-**sortBy:** `Optional` +**page:** `Optional` — Page number to retrieve.
@@ -2489,7 +4191,7 @@ client.datasets().listEntitiesInDataset(
-**sortOrder:** `Optional` +**pageSize:** `Optional` — Number of records per page.
@@ -2501,7 +4203,7 @@ client.datasets().listEntitiesInDataset(
-
client.datasets.getDatasetStatusHistory(datasetId) -> DatasetStatusHistoryResponse +
client.projects.addResourceToProject(projectId, request) -> AddResourceResponseDto
@@ -2513,7 +4215,7 @@ client.datasets().listEntitiesInDataset(
-Returns the full status change history for a dataset, ordered chronologically from oldest to newest. +Assigns one or more existing resources to a project in a single request.
@@ -2528,10 +4230,19 @@ Returns the full status change history for a dataset, ordered chronologically fr
```java -client.datasets().getDatasetStatusHistory( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - GetDatasetStatusHistoryRequest +client.projects().addResourceToProject( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + AddResourceRequestDto .builder() + .resources( + Arrays.asList( + ResourceItemDto + .builder() + .resourceType(ProjectResourceType.JOB) + .resourceId("48421e16-1f50-4048-b62c-d3bc0789d30d") + .build() + ) + ) .build() ); ``` @@ -2548,7 +4259,15 @@ client.datasets().getDatasetStatusHistory(
-**datasetId:** `String` — Unique dataset identifier. +**projectId:** `String` — Unique project identifier. + +
+
+ +
+
+ +**resources:** `List` — Resources to assign to the project.
@@ -2560,7 +4279,7 @@ client.datasets().getDatasetStatusHistory(
-
client.datasets.uploadCsvToDataset(datasetId, request) -> UploadCsvToDatasetResponse +
client.projects.removeResourceFromProject(projectId, resourceType, resourceId) -> RemoveResourceResponseDto
@@ -2572,9 +4291,8 @@ client.datasets().getDatasetStatusHistory(
-Appends new companies to an existing dataset by uploading a CSV file. Uses the same CSV format as the dataset creation endpoint. - -The response omits `dataset_name` compared to the create-from-CSV endpoint since the dataset already exists. +Removes a resource from a project. The resource itself is not +deleted — it becomes unassigned and continues to exist.
@@ -2589,10 +4307,11 @@ The response omits `dataset_name` compared to the create-from-CSV endpoint since
```java -client.datasets().uploadCsvToDataset( - "ccabb755-afc2-4047-b84c-78d1f23d49b2", - null, - UploadCsvToDatasetRequest +client.projects().removeResourceFromProject( + "60a85db4-78ec-4b78-876a-bc7d9cdadd04", + ProjectResourceType.JOB, + "48421e16-1f50-4048-b62c-d3bc0789d30d", + RemoveResourceFromProjectRequest .builder() .build() ); @@ -2610,7 +4329,23 @@ client.datasets().uploadCsvToDataset(
-**datasetId:** `String` — Unique dataset identifier. +**projectId:** `String` — Unique project identifier. + +
+
+ +
+
+ +**resourceType:** `ProjectResourceType` + +
+
+ +
+
+ +**resourceId:** `String` — ID of the resource to remove.
diff --git a/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java b/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java index e52a989..216ce3f 100644 --- a/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java +++ b/src/main/java/com/newscatcher/catchall/AsyncCatchAllApi.java @@ -10,6 +10,8 @@ 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 { @@ -19,18 +21,24 @@ public class AsyncCatchAllApi { protected final Supplier monitorsClient; + protected final Supplier webhooksClient; + protected final Supplier entitiesClient; protected final Supplier datasetsClient; + protected final Supplier projectsClient; + protected final Supplier metaClient; public AsyncCatchAllApi(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); this.monitorsClient = Suppliers.memoize(() -> new AsyncMonitorsClient(clientOptions)); + this.webhooksClient = Suppliers.memoize(() -> new AsyncWebhooksClient(clientOptions)); this.entitiesClient = Suppliers.memoize(() -> new AsyncEntitiesClient(clientOptions)); this.datasetsClient = Suppliers.memoize(() -> new AsyncDatasetsClient(clientOptions)); + this.projectsClient = Suppliers.memoize(() -> new AsyncProjectsClient(clientOptions)); this.metaClient = Suppliers.memoize(() -> new AsyncMetaClient(clientOptions)); } @@ -42,6 +50,10 @@ public AsyncMonitorsClient monitors() { return this.monitorsClient.get(); } + public AsyncWebhooksClient webhooks() { + return this.webhooksClient.get(); + } + public AsyncEntitiesClient entities() { return this.entitiesClient.get(); } @@ -50,6 +62,10 @@ public AsyncDatasetsClient datasets() { return this.datasetsClient.get(); } + public AsyncProjectsClient projects() { + return this.projectsClient.get(); + } + public AsyncMetaClient meta() { return this.metaClient.get(); } diff --git a/src/main/java/com/newscatcher/catchall/CatchAllApi.java b/src/main/java/com/newscatcher/catchall/CatchAllApi.java index ca5e7dd..f76e185 100644 --- a/src/main/java/com/newscatcher/catchall/CatchAllApi.java +++ b/src/main/java/com/newscatcher/catchall/CatchAllApi.java @@ -10,6 +10,8 @@ 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 { @@ -19,18 +21,24 @@ public class CatchAllApi { protected final Supplier monitorsClient; + protected final Supplier webhooksClient; + protected final Supplier entitiesClient; protected final Supplier datasetsClient; + protected final Supplier projectsClient; + protected final Supplier metaClient; public CatchAllApi(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions)); this.monitorsClient = Suppliers.memoize(() -> new MonitorsClient(clientOptions)); + this.webhooksClient = Suppliers.memoize(() -> new WebhooksClient(clientOptions)); this.entitiesClient = Suppliers.memoize(() -> new EntitiesClient(clientOptions)); this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions)); + this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions)); this.metaClient = Suppliers.memoize(() -> new MetaClient(clientOptions)); } @@ -42,6 +50,10 @@ public MonitorsClient monitors() { return this.monitorsClient.get(); } + public WebhooksClient webhooks() { + return this.webhooksClient.get(); + } + public EntitiesClient entities() { return this.entitiesClient.get(); } @@ -50,6 +62,10 @@ public DatasetsClient datasets() { return this.datasetsClient.get(); } + public ProjectsClient projects() { + return this.projectsClient.get(); + } + public MetaClient meta() { return this.metaClient.get(); } diff --git a/src/main/java/com/newscatcher/catchall/core/ClientOptions.java b/src/main/java/com/newscatcher/catchall/core/ClientOptions.java index ea3bc42..b35cc85 100644 --- a/src/main/java/com/newscatcher/catchall/core/ClientOptions.java +++ b/src/main/java/com/newscatcher/catchall/core/ClientOptions.java @@ -38,10 +38,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.newscatcherapi:newscatcher-catchall-sdk/2.0.0"); + put("User-Agent", "com.newscatcherapi:newscatcher-catchall-sdk/3.0.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.newscatcher.fern:api-sdk"); - put("X-Fern-SDK-Version", "2.0.0"); + put("X-Fern-SDK-Version", "3.0.0"); } }); this.headerSuppliers = headerSuppliers; 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 556327a..5f878f0 100644 --- a/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/datasets/AsyncRawDatasetsClient.java @@ -119,6 +119,10 @@ public CompletableFuture> listDatas QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); 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 f82adb3..5657b94 100644 --- a/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/datasets/RawDatasetsClient.java @@ -115,6 +115,10 @@ public CatchAllApiHttpResponse listDatasets( QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); diff --git a/src/main/java/com/newscatcher/catchall/resources/datasets/requests/ListDatasetsRequest.java b/src/main/java/com/newscatcher/catchall/resources/datasets/requests/ListDatasetsRequest.java index 04096f5..bb69160 100644 --- a/src/main/java/com/newscatcher/catchall/resources/datasets/requests/ListDatasetsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/datasets/requests/ListDatasetsRequest.java @@ -38,6 +38,8 @@ public final class ListDatasetsRequest { private final Optional ownership; + private final Optional projectId; + private final Map additionalProperties; private ListDatasetsRequest( @@ -48,6 +50,7 @@ private ListDatasetsRequest( Optional sortBy, Optional sortOrder, Optional ownership, + Optional projectId, Map additionalProperties) { this.page = page; this.pageSize = pageSize; @@ -56,6 +59,7 @@ private ListDatasetsRequest( this.sortBy = sortBy; this.sortOrder = sortOrder; this.ownership = ownership; + this.projectId = projectId; this.additionalProperties = additionalProperties; } @@ -106,6 +110,14 @@ public Optional getOwnership() { return ownership; } + /** + * @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; @@ -124,13 +136,21 @@ private boolean equalTo(ListDatasetsRequest other) { && latestStatus.equals(other.latestStatus) && sortBy.equals(other.sortBy) && sortOrder.equals(other.sortOrder) - && ownership.equals(other.ownership); + && ownership.equals(other.ownership) + && projectId.equals(other.projectId); } @java.lang.Override public int hashCode() { return Objects.hash( - this.page, this.pageSize, this.search, this.latestStatus, this.sortBy, this.sortOrder, this.ownership); + this.page, + this.pageSize, + this.search, + this.latestStatus, + this.sortBy, + this.sortOrder, + this.ownership, + this.projectId); } @java.lang.Override @@ -158,6 +178,8 @@ public static final class Builder { private Optional ownership = Optional.empty(); + private Optional projectId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -171,6 +193,7 @@ public Builder from(ListDatasetsRequest other) { sortBy(other.getSortBy()); sortOrder(other.getSortOrder()); ownership(other.getOwnership()); + projectId(other.getProjectId()); return this; } @@ -263,9 +286,31 @@ public Builder ownership(OwnershipFilter ownership) { 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 ListDatasetsRequest build() { return new ListDatasetsRequest( - page, pageSize, search, latestStatus, sortBy, sortOrder, ownership, additionalProperties); + page, + pageSize, + search, + latestStatus, + sortBy, + sortOrder, + ownership, + projectId, + additionalProperties); } public Builder additionalProperty(String key, Object value) { 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 b62d853..35f9792 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncJobsClient.java @@ -12,6 +12,7 @@ import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; 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; @@ -19,6 +20,7 @@ import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; import com.newscatcher.catchall.types.SubmitResponseDto; +import com.newscatcher.catchall.types.ValidateQueryResponseDto; import java.util.concurrent.CompletableFuture; public class AsyncJobsClient { @@ -67,6 +69,23 @@ public CompletableFuture getUserJobs( return this.rawClient.getUserJobs(request, requestOptions).thenApply(response -> response.body()); } + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CompletableFuture validateQuery(ValidateQueryRequestDto request) { + return this.rawClient.validateQuery(request).thenApply(response -> response.body()); + } + + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CompletableFuture validateQuery( + ValidateQueryRequestDto request, RequestOptions requestOptions) { + return this.rawClient.validateQuery(request, requestOptions).thenApply(response -> response.body()); + } + /** * Get suggested validators, enrichments, and date ranges for a query. */ 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 a24dab1..41e8a12 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/AsyncRawJobsClient.java @@ -24,6 +24,7 @@ import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; 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; @@ -32,6 +33,7 @@ import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; import com.newscatcher.catchall.types.SubmitResponseDto; +import com.newscatcher.catchall.types.ValidateQueryResponseDto; import com.newscatcher.catchall.types.ValidationErrorResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -99,6 +101,10 @@ public CompletableFuture> getUs QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); @@ -152,6 +158,93 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CompletableFuture> validateQuery( + ValidateQueryRequestDto request) { + return validateQuery(request, null); + } + + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CompletableFuture> validateQuery( + ValidateQueryRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/validate"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, ValidateQueryResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 403: + future.completeExceptionally(new ForbiddenError( + 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 (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; + } + /** * Get suggested validators, enrichments, and date ranges for a query. */ 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 99f2da8..2b1fec1 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/JobsClient.java @@ -12,6 +12,7 @@ import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; 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; @@ -19,6 +20,7 @@ import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; import com.newscatcher.catchall.types.SubmitResponseDto; +import com.newscatcher.catchall.types.ValidateQueryResponseDto; public class JobsClient { protected final ClientOptions clientOptions; @@ -65,6 +67,22 @@ public ListUserJobsResponseDto getUserJobs(GetUserJobsRequest request, RequestOp return this.rawClient.getUserJobs(request, requestOptions).body(); } + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public ValidateQueryResponseDto validateQuery(ValidateQueryRequestDto request) { + return this.rawClient.validateQuery(request).body(); + } + + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public ValidateQueryResponseDto validateQuery(ValidateQueryRequestDto request, RequestOptions requestOptions) { + return this.rawClient.validateQuery(request, requestOptions).body(); + } + /** * Get suggested validators, enrichments, and date ranges for a query. */ 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 2a2c7f7..842067a 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/RawJobsClient.java @@ -24,6 +24,7 @@ import com.newscatcher.catchall.resources.jobs.requests.GetUserJobsRequest; import com.newscatcher.catchall.resources.jobs.requests.InitializeRequestDto; 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; @@ -32,6 +33,7 @@ import com.newscatcher.catchall.types.PullJobResponseDto; import com.newscatcher.catchall.types.StatusResponseDto; import com.newscatcher.catchall.types.SubmitResponseDto; +import com.newscatcher.catchall.types.ValidateQueryResponseDto; import com.newscatcher.catchall.types.ValidationErrorResponse; import java.io.IOException; import okhttp3.Headers; @@ -94,6 +96,10 @@ public CatchAllApiHttpResponse getUserJobs( QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); @@ -133,6 +139,75 @@ public CatchAllApiHttpResponse getUserJobs( } } + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CatchAllApiHttpResponse validateQuery(ValidateQueryRequestDto request) { + return validateQuery(request, null); + } + + /** + * Checks whether a query is well-formed and likely to produce good results before submitting a job. + *

Returns a quality assessment with a status level, identified issues, and actionable suggestions.

+ */ + public CatchAllApiHttpResponse validateQuery( + ValidateQueryRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/validate"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, ValidateQueryResponseDto.class), + response); + } + try { + switch (response.code()) { + case 403: + throw new ForbiddenError( + 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + /** * Get suggested validators, enrichments, and date ranges for a query. */ diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/GetUserJobsRequest.java b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/GetUserJobsRequest.java index f4c7d5d..7198ba4 100644 --- a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/GetUserJobsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/GetUserJobsRequest.java @@ -29,6 +29,8 @@ public final class GetUserJobsRequest { private final Optional ownership; + private final Optional projectId; + private final Map additionalProperties; private GetUserJobsRequest( @@ -36,11 +38,13 @@ private GetUserJobsRequest( Optional pageSize, Optional search, Optional ownership, + Optional projectId, Map additionalProperties) { this.page = page; this.pageSize = pageSize; this.search = search; this.ownership = ownership; + this.projectId = projectId; this.additionalProperties = additionalProperties; } @@ -73,6 +77,14 @@ public Optional getOwnership() { return ownership; } + /** + * @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; @@ -88,12 +100,13 @@ private boolean equalTo(GetUserJobsRequest other) { return page.equals(other.page) && pageSize.equals(other.pageSize) && search.equals(other.search) - && ownership.equals(other.ownership); + && ownership.equals(other.ownership) + && projectId.equals(other.projectId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.page, this.pageSize, this.search, this.ownership); + return Objects.hash(this.page, this.pageSize, this.search, this.ownership, this.projectId); } @java.lang.Override @@ -115,6 +128,8 @@ public static final class Builder { private Optional ownership = Optional.empty(); + private Optional projectId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -125,6 +140,7 @@ public Builder from(GetUserJobsRequest other) { pageSize(other.getPageSize()); search(other.getSearch()); ownership(other.getOwnership()); + projectId(other.getProjectId()); return this; } @@ -181,8 +197,22 @@ public Builder ownership(OwnershipFilter ownership) { 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 GetUserJobsRequest build() { - return new GetUserJobsRequest(page, pageSize, search, ownership, additionalProperties); + return new GetUserJobsRequest(page, pageSize, search, ownership, projectId, additionalProperties); } public Builder additionalProperty(String key, Object value) { 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 2803a77..f6fdfd0 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 @@ -46,6 +46,10 @@ public final class SubmitRequestDto { private final Optional edScoreMin; + private final Optional projectId; + + private final Optional> webhookIds; + private final Map additionalProperties; private SubmitRequestDto( @@ -59,6 +63,8 @@ private SubmitRequestDto( Optional mode, Optional> connectedDatasetIds, Optional edScoreMin, + Optional projectId, + Optional> webhookIds, Map additionalProperties) { this.query = query; this.context = context; @@ -70,6 +76,8 @@ private SubmitRequestDto( this.mode = mode; this.connectedDatasetIds = connectedDatasetIds; this.edScoreMin = edScoreMin; + this.projectId = projectId; + this.webhookIds = webhookIds; this.additionalProperties = additionalProperties; } @@ -146,6 +154,22 @@ public Optional getEdScoreMin() { return edScoreMin; } + /** + * @return Project to assign this job to. The job appears in the project's resource list immediately after submission. + */ + @JsonProperty("project_id") + public Optional getProjectId() { + return projectId; + } + + /** + * @return IDs of webhooks to notify when the job completes. Maximum 5 per job. + */ + @JsonProperty("webhook_ids") + public Optional> getWebhookIds() { + return webhookIds; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -167,7 +191,9 @@ private boolean equalTo(SubmitRequestDto other) { && enrichments.equals(other.enrichments) && mode.equals(other.mode) && connectedDatasetIds.equals(other.connectedDatasetIds) - && edScoreMin.equals(other.edScoreMin); + && edScoreMin.equals(other.edScoreMin) + && projectId.equals(other.projectId) + && webhookIds.equals(other.webhookIds); } @java.lang.Override @@ -182,7 +208,9 @@ public int hashCode() { this.enrichments, this.mode, this.connectedDatasetIds, - this.edScoreMin); + this.edScoreMin, + this.projectId, + this.webhookIds); } @java.lang.Override @@ -265,12 +293,30 @@ public interface _FinalStage { _FinalStage edScoreMin(Optional edScoreMin); _FinalStage edScoreMin(Integer edScoreMin); + + /** + *

Project to assign this job to. The job appears in the project's resource list immediately after submission.

+ */ + _FinalStage projectId(Optional projectId); + + _FinalStage projectId(String projectId); + + /** + *

IDs of webhooks to notify when the job completes. Maximum 5 per job.

+ */ + _FinalStage webhookIds(Optional> webhookIds); + + _FinalStage webhookIds(List webhookIds); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements QueryStage, _FinalStage { private String query; + private Optional> webhookIds = Optional.empty(); + + private Optional projectId = Optional.empty(); + private Optional edScoreMin = Optional.empty(); private Optional> connectedDatasetIds = Optional.empty(); @@ -306,6 +352,8 @@ public Builder from(SubmitRequestDto other) { mode(other.getMode()); connectedDatasetIds(other.getConnectedDatasetIds()); edScoreMin(other.getEdScoreMin()); + projectId(other.getProjectId()); + webhookIds(other.getWebhookIds()); return this; } @@ -316,6 +364,46 @@ public _FinalStage query(@NotNull String query) { return this; } + /** + *

IDs of webhooks to notify when the job completes. Maximum 5 per job.

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

IDs of webhooks to notify when the job completes. Maximum 5 per job.

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

Project to assign this job to. The job appears in the project's resource list immediately after submission.

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

Project to assign this job to. The job appears in the project's resource list immediately after submission.

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

The minimum relevance score a connected entity must reach for its record to be included in results.

*

Only valid when connected_dataset_ids is set; otherwise ignored. Records where no connected entity meets the threshold are excluded entirely.

@@ -497,6 +585,8 @@ public SubmitRequestDto build() { mode, connectedDatasetIds, edScoreMin, + projectId, + webhookIds, additionalProperties); } diff --git a/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ValidateQueryRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ValidateQueryRequestDto.java new file mode 100644 index 0000000..e397345 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/jobs/requests/ValidateQueryRequestDto.java @@ -0,0 +1,129 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ValidateQueryRequestDto.Builder.class) +public final class ValidateQueryRequestDto { + private final String query; + + private final Map additionalProperties; + + private ValidateQueryRequestDto(String query, Map additionalProperties) { + this.query = query; + this.additionalProperties = additionalProperties; + } + + /** + * @return Plain text query to validate. + */ + @JsonProperty("query") + public String getQuery() { + return query; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ValidateQueryRequestDto && equalTo((ValidateQueryRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ValidateQueryRequestDto other) { + return query.equals(other.query); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.query); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QueryStage builder() { + return new Builder(); + } + + public interface QueryStage { + /** + *

Plain text query to validate.

+ */ + _FinalStage query(@NotNull String query); + + Builder from(ValidateQueryRequestDto other); + } + + public interface _FinalStage { + ValidateQueryRequestDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements QueryStage, _FinalStage { + private String query; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ValidateQueryRequestDto other) { + query(other.getQuery()); + return this; + } + + /** + *

Plain text query to validate.

+ *

Plain text query to validate.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("query") + public _FinalStage query(@NotNull String query) { + this.query = Objects.requireNonNull(query, "query must not be null"); + return this; + } + + @java.lang.Override + public ValidateQueryRequestDto build() { + return new ValidateQueryRequestDto(query, 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/resources/monitors/AsyncRawMonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java index 38c2f5e..0148d21 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/AsyncRawMonitorsClient.java @@ -103,6 +103,10 @@ public CompletableFuture> listM QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java b/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java index 368bfa3..e46d9f3 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/RawMonitorsClient.java @@ -97,6 +97,10 @@ public CatchAllApiHttpResponse listMonitors( QueryStringMapper.addQueryParameter( httpUrl, "ownership", request.getOwnership().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); diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java index 35d428c..f0e37d1 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/CreateMonitorRequestDto.java @@ -12,8 +12,8 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.catchall.core.ObjectMappers; -import com.newscatcher.catchall.types.WebhookDto; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -28,28 +28,32 @@ public final class CreateMonitorRequestDto { private final Optional timezone; - private final Optional webhook; + private final Optional> webhookIds; private final Optional limit; private final Optional backfill; + private final Optional projectId; + private final Map additionalProperties; private CreateMonitorRequestDto( String referenceJobId, String schedule, Optional timezone, - Optional webhook, + Optional> webhookIds, Optional limit, Optional backfill, + Optional projectId, Map additionalProperties) { this.referenceJobId = referenceJobId; this.schedule = schedule; this.timezone = timezone; - this.webhook = webhook; + this.webhookIds = webhookIds; this.limit = limit; this.backfill = backfill; + this.projectId = projectId; this.additionalProperties = additionalProperties; } @@ -80,11 +84,14 @@ public Optional getTimezone() { } /** - * @return Optional webhook to receive notifications when jobs complete. + * @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. */ - @JsonProperty("webhook") - public Optional getWebhook() { - return webhook; + @JsonProperty("webhook_ids") + public Optional> getWebhookIds() { + return webhookIds; } /** @@ -104,6 +111,14 @@ public Optional getBackfill() { return backfill; } + /** + * @return Project to assign this monitor to. The monitor appears in the project's resource list after creation. + */ + @JsonProperty("project_id") + public Optional getProjectId() { + return projectId; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -119,14 +134,22 @@ private boolean equalTo(CreateMonitorRequestDto other) { return referenceJobId.equals(other.referenceJobId) && schedule.equals(other.schedule) && timezone.equals(other.timezone) - && webhook.equals(other.webhook) + && webhookIds.equals(other.webhookIds) && limit.equals(other.limit) - && backfill.equals(other.backfill); + && backfill.equals(other.backfill) + && projectId.equals(other.projectId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.referenceJobId, this.schedule, this.timezone, this.webhook, this.limit, this.backfill); + return Objects.hash( + this.referenceJobId, + this.schedule, + this.timezone, + this.webhookIds, + this.limit, + this.backfill, + this.projectId); } @java.lang.Override @@ -171,11 +194,14 @@ public interface _FinalStage { _FinalStage timezone(String timezone); /** - *

Optional webhook to receive notifications when jobs complete.

+ *

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.

*/ - _FinalStage webhook(Optional webhook); + _FinalStage webhookIds(Optional> webhookIds); - _FinalStage webhook(WebhookDto webhook); + _FinalStage webhookIds(List webhookIds); /** *

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

@@ -191,6 +217,13 @@ public interface _FinalStage { _FinalStage backfill(Optional backfill); _FinalStage backfill(Boolean backfill); + + /** + *

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

+ */ + _FinalStage projectId(Optional projectId); + + _FinalStage projectId(String projectId); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -199,11 +232,13 @@ public static final class Builder implements ReferenceJobIdStage, ScheduleStage, private String schedule; + private Optional projectId = Optional.empty(); + private Optional backfill = Optional.empty(); private Optional limit = Optional.empty(); - private Optional webhook = Optional.empty(); + private Optional> webhookIds = Optional.empty(); private Optional timezone = Optional.empty(); @@ -217,9 +252,10 @@ public Builder from(CreateMonitorRequestDto other) { referenceJobId(other.getReferenceJobId()); schedule(other.getSchedule()); timezone(other.getTimezone()); - webhook(other.getWebhook()); + webhookIds(other.getWebhookIds()); limit(other.getLimit()); backfill(other.getBackfill()); + projectId(other.getProjectId()); return this; } @@ -249,6 +285,26 @@ public _FinalStage schedule(@NotNull String schedule) { return this; } + /** + *

Project to assign this monitor to. The 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 + public _FinalStage projectId(String projectId) { + this.projectId = Optional.ofNullable(projectId); + return this; + } + + /** + *

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

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

If true, fills the data gap between the reference job's end_date and the first scheduled run. The reference job's end_date must be within the last 7 days.

*

If false, no gap filling occurs and the first run uses the current cron window only — the reference job's age does not matter.

@@ -292,22 +348,28 @@ public _FinalStage limit(Optional limit) { } /** - *

Optional webhook to receive notifications when jobs complete.

+ *

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.

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

Optional webhook to receive notifications when jobs complete.

+ *

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.

*/ @java.lang.Override - @JsonSetter(value = "webhook", nulls = Nulls.SKIP) - public _FinalStage webhook(Optional webhook) { - this.webhook = webhook; + @JsonSetter(value = "webhook_ids", nulls = Nulls.SKIP) + public _FinalStage webhookIds(Optional> webhookIds) { + this.webhookIds = webhookIds; return this; } @@ -336,7 +398,7 @@ public _FinalStage timezone(Optional timezone) { @java.lang.Override public CreateMonitorRequestDto build() { return new CreateMonitorRequestDto( - referenceJobId, schedule, timezone, webhook, limit, backfill, additionalProperties); + referenceJobId, schedule, timezone, webhookIds, limit, backfill, projectId, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java index dc293af..9f19155 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/ListMonitorsRequest.java @@ -29,6 +29,8 @@ public final class ListMonitorsRequest { private final Optional ownership; + private final Optional projectId; + private final Map additionalProperties; private ListMonitorsRequest( @@ -36,11 +38,13 @@ private ListMonitorsRequest( Optional pageSize, Optional search, Optional ownership, + Optional projectId, Map additionalProperties) { this.page = page; this.pageSize = pageSize; this.search = search; this.ownership = ownership; + this.projectId = projectId; this.additionalProperties = additionalProperties; } @@ -73,6 +77,14 @@ public Optional getOwnership() { return ownership; } + /** + * @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; @@ -88,12 +100,13 @@ private boolean equalTo(ListMonitorsRequest other) { return page.equals(other.page) && pageSize.equals(other.pageSize) && search.equals(other.search) - && ownership.equals(other.ownership); + && ownership.equals(other.ownership) + && projectId.equals(other.projectId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.page, this.pageSize, this.search, this.ownership); + return Objects.hash(this.page, this.pageSize, this.search, this.ownership, this.projectId); } @java.lang.Override @@ -115,6 +128,8 @@ public static final class Builder { private Optional ownership = Optional.empty(); + private Optional projectId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -125,6 +140,7 @@ public Builder from(ListMonitorsRequest other) { pageSize(other.getPageSize()); search(other.getSearch()); ownership(other.getOwnership()); + projectId(other.getProjectId()); return this; } @@ -181,8 +197,22 @@ public Builder ownership(OwnershipFilter ownership) { 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 ListMonitorsRequest build() { - return new ListMonitorsRequest(page, pageSize, search, ownership, additionalProperties); + return new ListMonitorsRequest(page, pageSize, search, ownership, projectId, additionalProperties); } public Builder additionalProperty(String key, Object value) { 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 index 41bba95..9330a43 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/requests/UpdateMonitorRequestDto.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/requests/UpdateMonitorRequestDto.java @@ -12,8 +12,8 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.catchall.core.ObjectMappers; -import com.newscatcher.catchall.types.WebhookDto; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,25 +21,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateMonitorRequestDto.Builder.class) public final class UpdateMonitorRequestDto { - private final Optional webhook; + private final Optional> webhookIds; private final Optional limit; private final Map additionalProperties; private UpdateMonitorRequestDto( - Optional webhook, Optional limit, Map additionalProperties) { - this.webhook = webhook; + Optional> webhookIds, Optional limit, Map additionalProperties) { + this.webhookIds = webhookIds; this.limit = limit; this.additionalProperties = additionalProperties; } /** - * @return Updated webhook configuration. + * @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") - public Optional getWebhook() { - return webhook; + @JsonProperty("webhook_ids") + public Optional> getWebhookIds() { + return webhookIds; } /** @@ -62,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateMonitorRequestDto other) { - return webhook.equals(other.webhook) && limit.equals(other.limit); + return webhookIds.equals(other.webhookIds) && limit.equals(other.limit); } @java.lang.Override public int hashCode() { - return Objects.hash(this.webhook, this.limit); + return Objects.hash(this.webhookIds, this.limit); } @java.lang.Override @@ -81,7 +82,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional webhook = Optional.empty(); + private Optional> webhookIds = Optional.empty(); private Optional limit = Optional.empty(); @@ -91,22 +92,23 @@ public static final class Builder { private Builder() {} public Builder from(UpdateMonitorRequestDto other) { - webhook(other.getWebhook()); + webhookIds(other.getWebhookIds()); limit(other.getLimit()); return this; } /** - *

Updated webhook configuration.

+ *

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", nulls = Nulls.SKIP) - public Builder webhook(Optional webhook) { - this.webhook = webhook; + @JsonSetter(value = "webhook_ids", nulls = Nulls.SKIP) + public Builder webhookIds(Optional> webhookIds) { + this.webhookIds = webhookIds; return this; } - public Builder webhook(WebhookDto webhook) { - this.webhook = Optional.ofNullable(webhook); + public Builder webhookIds(List webhookIds) { + this.webhookIds = Optional.ofNullable(webhookIds); return this; } @@ -125,7 +127,7 @@ public Builder limit(Integer limit) { } public UpdateMonitorRequestDto build() { - return new UpdateMonitorRequestDto(webhook, limit, additionalProperties); + return new UpdateMonitorRequestDto(webhookIds, limit, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java b/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java index 6621eec..982bb00 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/types/DisableMonitorResponse.java @@ -36,7 +36,7 @@ private DisableMonitorResponse( } /** - * @return Whether the operation succeeded. + * @return True if the operation succeeded; false otherwise. */ @JsonProperty("success") public boolean getSuccess() { @@ -90,7 +90,7 @@ public static SuccessStage builder() { public interface SuccessStage { /** - *

Whether the operation succeeded.

+ *

True if the operation succeeded; false otherwise.

*/ MessageStage success(boolean success); @@ -141,8 +141,8 @@ public Builder from(DisableMonitorResponse other) { } /** - *

Whether the operation succeeded.

- *

Whether the operation succeeded.

+ *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

* @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/monitors/types/EnableMonitorResponse.java index e9b9760..95ac68a 100644 --- a/src/main/java/com/newscatcher/catchall/resources/monitors/types/EnableMonitorResponse.java +++ b/src/main/java/com/newscatcher/catchall/resources/monitors/types/EnableMonitorResponse.java @@ -36,7 +36,7 @@ private EnableMonitorResponse( } /** - * @return Whether the operation succeeded. + * @return True if the operation succeeded; false otherwise. */ @JsonProperty("success") public boolean getSuccess() { @@ -90,7 +90,7 @@ public static SuccessStage builder() { public interface SuccessStage { /** - *

Whether the operation succeeded.

+ *

True if the operation succeeded; false otherwise.

*/ MessageStage success(boolean success); @@ -141,8 +141,8 @@ public Builder from(EnableMonitorResponse other) { } /** - *

Whether the operation succeeded.

- *

Whether the operation succeeded.

+ *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

* @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/projects/AsyncProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncProjectsClient.java new file mode 100644 index 0000000..01493ac --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncProjectsClient.java @@ -0,0 +1,315 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects; + +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.resources.projects.requests.AddResourceRequestDto; +import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; +import com.newscatcher.catchall.resources.projects.requests.DeleteProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectOverviewRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectResourcesRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectsRequest; +import com.newscatcher.catchall.resources.projects.requests.RemoveResourceFromProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.UpdateProjectRequestDto; +import com.newscatcher.catchall.types.AddResourceResponseDto; +import com.newscatcher.catchall.types.CreateProjectResponseDto; +import com.newscatcher.catchall.types.ProjectListResponseDto; +import com.newscatcher.catchall.types.ProjectOverviewResponseDto; +import com.newscatcher.catchall.types.ProjectResourceListResponseDto; +import com.newscatcher.catchall.types.ProjectResourceType; +import com.newscatcher.catchall.types.ProjectResponseDto; +import com.newscatcher.catchall.types.RemoveResourceResponseDto; +import com.newscatcher.catchall.types.UpdateProjectResponseDto; +import java.util.concurrent.CompletableFuture; + +public class AsyncProjectsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawProjectsClient rawClient; + + public AsyncProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawProjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawProjectsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture listProjects() { + return this.rawClient.listProjects().thenApply(response -> response.body()); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture listProjects(RequestOptions requestOptions) { + return this.rawClient.listProjects(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture listProjects(ListProjectsRequest request) { + return this.rawClient.listProjects(request).thenApply(response -> response.body()); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture listProjects( + ListProjectsRequest request, RequestOptions requestOptions) { + return this.rawClient.listProjects(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a new project. + */ + public CompletableFuture createProject(CreateProjectRequestDto request) { + return this.rawClient.createProject(request).thenApply(response -> response.body()); + } + + /** + * Creates a new project. + */ + public CompletableFuture createProject( + CreateProjectRequestDto request, RequestOptions requestOptions) { + return this.rawClient.createProject(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture getProject(String projectId) { + return this.rawClient.getProject(projectId).thenApply(response -> response.body()); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture getProject(String projectId, RequestOptions requestOptions) { + return this.rawClient.getProject(projectId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture getProject(String projectId, GetProjectRequest request) { + return this.rawClient.getProject(projectId, request).thenApply(response -> response.body()); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture getProject( + String projectId, GetProjectRequest request, RequestOptions requestOptions) { + return this.rawClient.getProject(projectId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture deleteProject(String projectId) { + return this.rawClient.deleteProject(projectId).thenApply(response -> response.body()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture deleteProject(String projectId, RequestOptions requestOptions) { + return this.rawClient.deleteProject(projectId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture deleteProject(String projectId, DeleteProjectRequest request) { + return this.rawClient.deleteProject(projectId, request).thenApply(response -> response.body()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture deleteProject( + String projectId, DeleteProjectRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteProject(projectId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture updateProject(String projectId) { + return this.rawClient.updateProject(projectId).thenApply(response -> response.body()); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture updateProject(String projectId, RequestOptions requestOptions) { + return this.rawClient.updateProject(projectId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture updateProject( + String projectId, UpdateProjectRequestDto request) { + return this.rawClient.updateProject(projectId, request).thenApply(response -> response.body()); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture updateProject( + String projectId, UpdateProjectRequestDto request, RequestOptions requestOptions) { + return this.rawClient.updateProject(projectId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture getProjectOverview(String projectId) { + return this.rawClient.getProjectOverview(projectId).thenApply(response -> response.body()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture getProjectOverview( + String projectId, RequestOptions requestOptions) { + return this.rawClient.getProjectOverview(projectId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture getProjectOverview( + String projectId, GetProjectOverviewRequest request) { + return this.rawClient.getProjectOverview(projectId, request).thenApply(response -> response.body()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture getProjectOverview( + String projectId, GetProjectOverviewRequest request, RequestOptions requestOptions) { + return this.rawClient + .getProjectOverview(projectId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture listProjectResources(String projectId) { + return this.rawClient.listProjectResources(projectId).thenApply(response -> response.body()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture listProjectResources( + String projectId, RequestOptions requestOptions) { + return this.rawClient.listProjectResources(projectId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture listProjectResources( + String projectId, ListProjectResourcesRequest request) { + return this.rawClient.listProjectResources(projectId, request).thenApply(response -> response.body()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture listProjectResources( + String projectId, ListProjectResourcesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listProjectResources(projectId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CompletableFuture addResourceToProject( + String projectId, AddResourceRequestDto request) { + return this.rawClient.addResourceToProject(projectId, request).thenApply(response -> response.body()); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CompletableFuture addResourceToProject( + String projectId, AddResourceRequestDto request, RequestOptions requestOptions) { + return this.rawClient + .addResourceToProject(projectId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId) + .thenApply(response -> response.body()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, request) + .thenApply(response -> response.body()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request, + RequestOptions requestOptions) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java new file mode 100644 index 0000000..dfc5eff --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/AsyncRawProjectsClient.java @@ -0,0 +1,964 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.newscatcher.catchall.core.CatchAllApiApiException; +import com.newscatcher.catchall.core.CatchAllApiException; +import com.newscatcher.catchall.core.CatchAllApiHttpResponse; +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.MediaTypes; +import com.newscatcher.catchall.core.ObjectMappers; +import com.newscatcher.catchall.core.QueryStringMapper; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.errors.BadRequestError; +import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.NotFoundError; +import com.newscatcher.catchall.errors.UnprocessableEntityError; +import com.newscatcher.catchall.resources.projects.requests.AddResourceRequestDto; +import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; +import com.newscatcher.catchall.resources.projects.requests.DeleteProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectOverviewRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectResourcesRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectsRequest; +import com.newscatcher.catchall.resources.projects.requests.RemoveResourceFromProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.UpdateProjectRequestDto; +import com.newscatcher.catchall.types.AddResourceResponseDto; +import com.newscatcher.catchall.types.CreateProjectResponseDto; +import com.newscatcher.catchall.types.Error; +import com.newscatcher.catchall.types.ProjectListResponseDto; +import com.newscatcher.catchall.types.ProjectOverviewResponseDto; +import com.newscatcher.catchall.types.ProjectResourceListResponseDto; +import com.newscatcher.catchall.types.ProjectResourceType; +import com.newscatcher.catchall.types.ProjectResponseDto; +import com.newscatcher.catchall.types.RemoveResourceResponseDto; +import com.newscatcher.catchall.types.UpdateProjectResponseDto; +import com.newscatcher.catchall.types.ValidationErrorResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawProjectsClient { + protected final ClientOptions clientOptions; + + public AsyncRawProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture> listProjects() { + return listProjects(ListProjectsRequest.builder().build()); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture> listProjects( + RequestOptions requestOptions) { + return listProjects(ListProjectsRequest.builder().build(), requestOptions); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture> listProjects( + ListProjectsRequest request) { + return listProjects(request, null); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CompletableFuture> listProjects( + ListProjectsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects"); + 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 (request.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "search", request.getSearch().get(), false); + } + if (request.getOwnership().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ownership", request.getOwnership().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); + } + 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, ProjectListResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 403: + future.completeExceptionally(new ForbiddenError( + 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 (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; + } + + /** + * Creates a new project. + */ + public CompletableFuture> createProject( + CreateProjectRequestDto request) { + return createProject(request, null); + } + + /** + * Creates a new project. + */ + public CompletableFuture> createProject( + CreateProjectRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, CreateProjectResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 403: + future.completeExceptionally(new ForbiddenError( + 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 (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; + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture> getProject(String projectId) { + return getProject(projectId, GetProjectRequest.builder().build()); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture> getProject( + String projectId, RequestOptions requestOptions) { + return getProject(projectId, GetProjectRequest.builder().build(), requestOptions); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture> getProject( + String projectId, GetProjectRequest request) { + return getProject(projectId, request, null); + } + + /** + * Returns a single project by ID. + */ + public CompletableFuture> getProject( + String projectId, GetProjectRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + 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); + } + 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, ProjectResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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; + } + } 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 (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; + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture> deleteProject(String projectId) { + return deleteProject(projectId, DeleteProjectRequest.builder().build()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture> deleteProject( + String projectId, RequestOptions requestOptions) { + return deleteProject(projectId, DeleteProjectRequest.builder().build(), requestOptions); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture> deleteProject( + String projectId, DeleteProjectRequest request) { + return deleteProject(projectId, request, null); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CompletableFuture> deleteProject( + String projectId, DeleteProjectRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + if (request.getDeleteResources().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "delete_resources", request.getDeleteResources().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + 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()) { + if (response.isSuccessful()) { + future.complete(new CatchAllApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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; + } + } 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 (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; + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture> updateProject(String projectId) { + return updateProject(projectId, UpdateProjectRequestDto.builder().build()); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture> updateProject( + String projectId, RequestOptions requestOptions) { + return updateProject(projectId, UpdateProjectRequestDto.builder().build(), requestOptions); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture> updateProject( + String projectId, UpdateProjectRequestDto request) { + return updateProject(projectId, request, null); + } + + /** + * Updates the name or description of an existing project. + */ + public CompletableFuture> updateProject( + String projectId, UpdateProjectRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, UpdateProjectResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture> getProjectOverview(String projectId) { + return getProjectOverview(projectId, GetProjectOverviewRequest.builder().build()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture> getProjectOverview( + String projectId, RequestOptions requestOptions) { + return getProjectOverview(projectId, GetProjectOverviewRequest.builder().build(), requestOptions); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture> getProjectOverview( + String projectId, GetProjectOverviewRequest request) { + return getProjectOverview(projectId, request, null); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CompletableFuture> getProjectOverview( + String projectId, GetProjectOverviewRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("overview"); + 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); + } + 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, ProjectOverviewResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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; + } + } 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 (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; + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture> listProjectResources( + String projectId) { + return listProjectResources( + projectId, ListProjectResourcesRequest.builder().build()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture> listProjectResources( + String projectId, RequestOptions requestOptions) { + return listProjectResources( + projectId, ListProjectResourcesRequest.builder().build(), requestOptions); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture> listProjectResources( + String projectId, ListProjectResourcesRequest request) { + return listProjectResources(projectId, request, null); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CompletableFuture> listProjectResources( + String projectId, ListProjectResourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources"); + if (request.getResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "resource_type", request.getResourceType().get(), false); + } + 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); + } + 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, ProjectResourceListResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CompletableFuture> addResourceToProject( + String projectId, AddResourceRequestDto request) { + return addResourceToProject(projectId, request, null); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CompletableFuture> addResourceToProject( + String projectId, AddResourceRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, AddResourceResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.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; + } + } 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 (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; + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture> removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId) { + return removeResourceFromProject( + projectId, + resourceType, + resourceId, + RemoveResourceFromProjectRequest.builder().build()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture> removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return removeResourceFromProject( + projectId, + resourceType, + resourceId, + RemoveResourceFromProjectRequest.builder().build(), + requestOptions); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture> removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request) { + return removeResourceFromProject(projectId, resourceType, resourceId, request, null); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CompletableFuture> removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + 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, RemoveResourceResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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; + } + } 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 (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/projects/ProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/ProjectsClient.java new file mode 100644 index 0000000..9f88dc4 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/ProjectsClient.java @@ -0,0 +1,304 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects; + +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.resources.projects.requests.AddResourceRequestDto; +import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; +import com.newscatcher.catchall.resources.projects.requests.DeleteProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectOverviewRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectResourcesRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectsRequest; +import com.newscatcher.catchall.resources.projects.requests.RemoveResourceFromProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.UpdateProjectRequestDto; +import com.newscatcher.catchall.types.AddResourceResponseDto; +import com.newscatcher.catchall.types.CreateProjectResponseDto; +import com.newscatcher.catchall.types.ProjectListResponseDto; +import com.newscatcher.catchall.types.ProjectOverviewResponseDto; +import com.newscatcher.catchall.types.ProjectResourceListResponseDto; +import com.newscatcher.catchall.types.ProjectResourceType; +import com.newscatcher.catchall.types.ProjectResponseDto; +import com.newscatcher.catchall.types.RemoveResourceResponseDto; +import com.newscatcher.catchall.types.UpdateProjectResponseDto; + +public class ProjectsClient { + protected final ClientOptions clientOptions; + + private final RawProjectsClient rawClient; + + public ProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawProjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawProjectsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns all projects visible to the authenticated user. + */ + public ProjectListResponseDto listProjects() { + return this.rawClient.listProjects().body(); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public ProjectListResponseDto listProjects(RequestOptions requestOptions) { + return this.rawClient.listProjects(requestOptions).body(); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public ProjectListResponseDto listProjects(ListProjectsRequest request) { + return this.rawClient.listProjects(request).body(); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public ProjectListResponseDto listProjects(ListProjectsRequest request, RequestOptions requestOptions) { + return this.rawClient.listProjects(request, requestOptions).body(); + } + + /** + * Creates a new project. + */ + public CreateProjectResponseDto createProject(CreateProjectRequestDto request) { + return this.rawClient.createProject(request).body(); + } + + /** + * Creates a new project. + */ + public CreateProjectResponseDto createProject(CreateProjectRequestDto request, RequestOptions requestOptions) { + return this.rawClient.createProject(request, requestOptions).body(); + } + + /** + * Returns a single project by ID. + */ + public ProjectResponseDto getProject(String projectId) { + return this.rawClient.getProject(projectId).body(); + } + + /** + * Returns a single project by ID. + */ + public ProjectResponseDto getProject(String projectId, RequestOptions requestOptions) { + return this.rawClient.getProject(projectId, requestOptions).body(); + } + + /** + * Returns a single project by ID. + */ + public ProjectResponseDto getProject(String projectId, GetProjectRequest request) { + return this.rawClient.getProject(projectId, request).body(); + } + + /** + * Returns a single project by ID. + */ + public ProjectResponseDto getProject(String projectId, GetProjectRequest request, RequestOptions requestOptions) { + return this.rawClient.getProject(projectId, request, requestOptions).body(); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public void deleteProject(String projectId) { + this.rawClient.deleteProject(projectId).body(); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public void deleteProject(String projectId, RequestOptions requestOptions) { + this.rawClient.deleteProject(projectId, requestOptions).body(); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public void deleteProject(String projectId, DeleteProjectRequest request) { + this.rawClient.deleteProject(projectId, request).body(); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public void deleteProject(String projectId, DeleteProjectRequest request, RequestOptions requestOptions) { + this.rawClient.deleteProject(projectId, request, requestOptions).body(); + } + + /** + * Updates the name or description of an existing project. + */ + public UpdateProjectResponseDto updateProject(String projectId) { + return this.rawClient.updateProject(projectId).body(); + } + + /** + * Updates the name or description of an existing project. + */ + public UpdateProjectResponseDto updateProject(String projectId, RequestOptions requestOptions) { + return this.rawClient.updateProject(projectId, requestOptions).body(); + } + + /** + * Updates the name or description of an existing project. + */ + public UpdateProjectResponseDto updateProject(String projectId, UpdateProjectRequestDto request) { + return this.rawClient.updateProject(projectId, request).body(); + } + + /** + * Updates the name or description of an existing project. + */ + public UpdateProjectResponseDto updateProject( + String projectId, UpdateProjectRequestDto request, RequestOptions requestOptions) { + return this.rawClient.updateProject(projectId, request, requestOptions).body(); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public ProjectOverviewResponseDto getProjectOverview(String projectId) { + return this.rawClient.getProjectOverview(projectId).body(); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public ProjectOverviewResponseDto getProjectOverview(String projectId, RequestOptions requestOptions) { + return this.rawClient.getProjectOverview(projectId, requestOptions).body(); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public ProjectOverviewResponseDto getProjectOverview(String projectId, GetProjectOverviewRequest request) { + return this.rawClient.getProjectOverview(projectId, request).body(); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public ProjectOverviewResponseDto getProjectOverview( + String projectId, GetProjectOverviewRequest request, RequestOptions requestOptions) { + return this.rawClient + .getProjectOverview(projectId, request, requestOptions) + .body(); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public ProjectResourceListResponseDto listProjectResources(String projectId) { + return this.rawClient.listProjectResources(projectId).body(); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public ProjectResourceListResponseDto listProjectResources(String projectId, RequestOptions requestOptions) { + return this.rawClient.listProjectResources(projectId, requestOptions).body(); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public ProjectResourceListResponseDto listProjectResources(String projectId, ListProjectResourcesRequest request) { + return this.rawClient.listProjectResources(projectId, request).body(); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public ProjectResourceListResponseDto listProjectResources( + String projectId, ListProjectResourcesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listProjectResources(projectId, request, requestOptions) + .body(); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public AddResourceResponseDto addResourceToProject(String projectId, AddResourceRequestDto request) { + return this.rawClient.addResourceToProject(projectId, request).body(); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public AddResourceResponseDto addResourceToProject( + String projectId, AddResourceRequestDto request, RequestOptions requestOptions) { + return this.rawClient + .addResourceToProject(projectId, request, requestOptions) + .body(); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public RemoveResourceResponseDto removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId) + .body(); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public RemoveResourceResponseDto removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, requestOptions) + .body(); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public RemoveResourceResponseDto removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, request) + .body(); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public RemoveResourceResponseDto removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request, + RequestOptions requestOptions) { + return this.rawClient + .removeResourceFromProject(projectId, resourceType, resourceId, request, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java b/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java new file mode 100644 index 0000000..d2871f2 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/RawProjectsClient.java @@ -0,0 +1,789 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.newscatcher.catchall.core.CatchAllApiApiException; +import com.newscatcher.catchall.core.CatchAllApiException; +import com.newscatcher.catchall.core.CatchAllApiHttpResponse; +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.MediaTypes; +import com.newscatcher.catchall.core.ObjectMappers; +import com.newscatcher.catchall.core.QueryStringMapper; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.errors.BadRequestError; +import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.NotFoundError; +import com.newscatcher.catchall.errors.UnprocessableEntityError; +import com.newscatcher.catchall.resources.projects.requests.AddResourceRequestDto; +import com.newscatcher.catchall.resources.projects.requests.CreateProjectRequestDto; +import com.newscatcher.catchall.resources.projects.requests.DeleteProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectOverviewRequest; +import com.newscatcher.catchall.resources.projects.requests.GetProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectResourcesRequest; +import com.newscatcher.catchall.resources.projects.requests.ListProjectsRequest; +import com.newscatcher.catchall.resources.projects.requests.RemoveResourceFromProjectRequest; +import com.newscatcher.catchall.resources.projects.requests.UpdateProjectRequestDto; +import com.newscatcher.catchall.types.AddResourceResponseDto; +import com.newscatcher.catchall.types.CreateProjectResponseDto; +import com.newscatcher.catchall.types.Error; +import com.newscatcher.catchall.types.ProjectListResponseDto; +import com.newscatcher.catchall.types.ProjectOverviewResponseDto; +import com.newscatcher.catchall.types.ProjectResourceListResponseDto; +import com.newscatcher.catchall.types.ProjectResourceType; +import com.newscatcher.catchall.types.ProjectResponseDto; +import com.newscatcher.catchall.types.RemoveResourceResponseDto; +import com.newscatcher.catchall.types.UpdateProjectResponseDto; +import com.newscatcher.catchall.types.ValidationErrorResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawProjectsClient { + protected final ClientOptions clientOptions; + + public RawProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CatchAllApiHttpResponse listProjects() { + return listProjects(ListProjectsRequest.builder().build()); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CatchAllApiHttpResponse listProjects(RequestOptions requestOptions) { + return listProjects(ListProjectsRequest.builder().build(), requestOptions); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CatchAllApiHttpResponse listProjects(ListProjectsRequest request) { + return listProjects(request, null); + } + + /** + * Returns all projects visible to the authenticated user. + */ + public CatchAllApiHttpResponse listProjects( + ListProjectsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects"); + 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 (request.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "search", request.getSearch().get(), false); + } + if (request.getOwnership().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ownership", request.getOwnership().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); + } + 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, ProjectListResponseDto.class), + response); + } + try { + switch (response.code()) { + case 403: + throw new ForbiddenError( + 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Creates a new project. + */ + public CatchAllApiHttpResponse createProject(CreateProjectRequestDto request) { + return createProject(request, null); + } + + /** + * Creates a new project. + */ + public CatchAllApiHttpResponse createProject( + CreateProjectRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, CreateProjectResponseDto.class), + response); + } + try { + switch (response.code()) { + case 403: + throw new ForbiddenError( + 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns a single project by ID. + */ + public CatchAllApiHttpResponse getProject(String projectId) { + return getProject(projectId, GetProjectRequest.builder().build()); + } + + /** + * Returns a single project by ID. + */ + public CatchAllApiHttpResponse getProject(String projectId, RequestOptions requestOptions) { + return getProject(projectId, GetProjectRequest.builder().build(), requestOptions); + } + + /** + * Returns a single project by ID. + */ + public CatchAllApiHttpResponse getProject(String projectId, GetProjectRequest request) { + return getProject(projectId, request, null); + } + + /** + * Returns a single project by ID. + */ + public CatchAllApiHttpResponse getProject( + String projectId, GetProjectRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + 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); + } + 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, ProjectResponseDto.class), response); + } + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CatchAllApiHttpResponse deleteProject(String projectId) { + return deleteProject(projectId, DeleteProjectRequest.builder().build()); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CatchAllApiHttpResponse deleteProject(String projectId, RequestOptions requestOptions) { + return deleteProject(projectId, DeleteProjectRequest.builder().build(), requestOptions); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CatchAllApiHttpResponse deleteProject(String projectId, DeleteProjectRequest request) { + return deleteProject(projectId, request, null); + } + + /** + * Deletes a project. By default, assigned resources are unassigned but not deleted. + */ + public CatchAllApiHttpResponse deleteProject( + String projectId, DeleteProjectRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + if (request.getDeleteResources().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "delete_resources", request.getDeleteResources().get(), false); + } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new CatchAllApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Updates the name or description of an existing project. + */ + public CatchAllApiHttpResponse updateProject(String projectId) { + return updateProject(projectId, UpdateProjectRequestDto.builder().build()); + } + + /** + * Updates the name or description of an existing project. + */ + public CatchAllApiHttpResponse updateProject( + String projectId, RequestOptions requestOptions) { + return updateProject(projectId, UpdateProjectRequestDto.builder().build(), requestOptions); + } + + /** + * Updates the name or description of an existing project. + */ + public CatchAllApiHttpResponse updateProject( + String projectId, UpdateProjectRequestDto request) { + return updateProject(projectId, request, null); + } + + /** + * Updates the name or description of an existing project. + */ + public CatchAllApiHttpResponse updateProject( + String projectId, UpdateProjectRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, UpdateProjectResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CatchAllApiHttpResponse getProjectOverview(String projectId) { + return getProjectOverview(projectId, GetProjectOverviewRequest.builder().build()); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CatchAllApiHttpResponse getProjectOverview( + String projectId, RequestOptions requestOptions) { + return getProjectOverview(projectId, GetProjectOverviewRequest.builder().build(), requestOptions); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CatchAllApiHttpResponse getProjectOverview( + String projectId, GetProjectOverviewRequest request) { + return getProjectOverview(projectId, request, null); + } + + /** + * Returns resource counts for a project, grouped by type and status. + *

For jobs and monitors, counts are broken down by status (for example, completed, failed). For datasets and monitor_groups, only a total count is returned.

+ */ + public CatchAllApiHttpResponse getProjectOverview( + String projectId, GetProjectOverviewRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("overview"); + 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); + } + 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, ProjectOverviewResponseDto.class), + response); + } + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CatchAllApiHttpResponse listProjectResources(String projectId) { + return listProjectResources( + projectId, ListProjectResourcesRequest.builder().build()); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CatchAllApiHttpResponse listProjectResources( + String projectId, RequestOptions requestOptions) { + return listProjectResources( + projectId, ListProjectResourcesRequest.builder().build(), requestOptions); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CatchAllApiHttpResponse listProjectResources( + String projectId, ListProjectResourcesRequest request) { + return listProjectResources(projectId, request, null); + } + + /** + * Returns all resources assigned to a project, with optional filtering by type. + */ + public CatchAllApiHttpResponse listProjectResources( + String projectId, ListProjectResourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources"); + if (request.getResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "resource_type", request.getResourceType().get(), false); + } + 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); + } + 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, ProjectResourceListResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CatchAllApiHttpResponse addResourceToProject( + String projectId, AddResourceRequestDto request) { + return addResourceToProject(projectId, request, null); + } + + /** + * Assigns one or more existing resources to a project in a single request. + */ + public CatchAllApiHttpResponse addResourceToProject( + String projectId, AddResourceRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, AddResourceResponseDto.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CatchAllApiHttpResponse removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId) { + return removeResourceFromProject( + projectId, + resourceType, + resourceId, + RemoveResourceFromProjectRequest.builder().build()); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CatchAllApiHttpResponse removeResourceFromProject( + String projectId, ProjectResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return removeResourceFromProject( + projectId, + resourceType, + resourceId, + RemoveResourceFromProjectRequest.builder().build(), + requestOptions); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CatchAllApiHttpResponse removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request) { + return removeResourceFromProject(projectId, resourceType, resourceId, request, null); + } + + /** + * Removes a resource from a project. The resource itself is not + * deleted — it becomes unassigned and continues to exist. + */ + public CatchAllApiHttpResponse removeResourceFromProject( + String projectId, + ProjectResourceType resourceType, + String resourceId, + RemoveResourceFromProjectRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/projects") + .addPathSegment(projectId) + .addPathSegments("resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + 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, RemoveResourceResponseDto.class), + response); + } + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/projects/requests/AddResourceRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/AddResourceRequestDto.java new file mode 100644 index 0000000..b2b72da --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/AddResourceRequestDto.java @@ -0,0 +1,123 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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 com.newscatcher.catchall.types.ResourceItemDto; +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 = AddResourceRequestDto.Builder.class) +public final class AddResourceRequestDto { + private final List resources; + + private final Map additionalProperties; + + private AddResourceRequestDto(List resources, Map additionalProperties) { + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + /** + * @return Resources to assign to the project. + */ + @JsonProperty("resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AddResourceRequestDto && equalTo((AddResourceRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AddResourceRequestDto other) { + return resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resources); + } + + @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 List resources = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AddResourceRequestDto other) { + resources(other.getResources()); + return this; + } + + /** + *

Resources to assign to the project.

+ */ + @JsonSetter(value = "resources", nulls = Nulls.SKIP) + public Builder resources(List resources) { + this.resources.clear(); + if (resources != null) { + this.resources.addAll(resources); + } + return this; + } + + public Builder addResources(ResourceItemDto resources) { + this.resources.add(resources); + return this; + } + + public Builder addAllResources(List resources) { + if (resources != null) { + this.resources.addAll(resources); + } + return this; + } + + public AddResourceRequestDto build() { + return new AddResourceRequestDto(resources, 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/requests/CreateProjectRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/CreateProjectRequestDto.java new file mode 100644 index 0000000..d89c0ad --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/CreateProjectRequestDto.java @@ -0,0 +1,173 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateProjectRequestDto.Builder.class) +public final class CreateProjectRequestDto { + private final String name; + + private final Optional description; + + private final Map additionalProperties; + + private CreateProjectRequestDto( + String name, Optional description, Map additionalProperties) { + this.name = name; + this.description = description; + this.additionalProperties = additionalProperties; + } + + /** + * @return Name for the project. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Optional description. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateProjectRequestDto && equalTo((CreateProjectRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateProjectRequestDto other) { + return name.equals(other.name) && description.equals(other.description); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + /** + *

Name for the project.

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

Optional description.

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

Name for the project.

+ *

Name for the project.

+ * @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; + } + + /** + *

Optional description.

+ * @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; + } + + /** + *

Optional description.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateProjectRequestDto build() { + return new CreateProjectRequestDto(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/resources/projects/requests/DeleteProjectRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java new file mode 100644 index 0000000..de000e9 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/DeleteProjectRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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 = DeleteProjectRequest.Builder.class) +public final class DeleteProjectRequest { + private final Optional deleteResources; + + private final Map additionalProperties; + + private DeleteProjectRequest(Optional deleteResources, Map additionalProperties) { + this.deleteResources = deleteResources; + this.additionalProperties = additionalProperties; + } + + /** + * @return If true, permanently deletes all resources (jobs, monitors, datasets) assigned to the project. If false, the project is deleted and its resources are unassigned but not deleted. + */ + @JsonProperty("delete_resources") + public Optional getDeleteResources() { + return deleteResources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteProjectRequest && equalTo((DeleteProjectRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteProjectRequest other) { + return deleteResources.equals(other.deleteResources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.deleteResources); + } + + @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 deleteResources = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteProjectRequest other) { + deleteResources(other.getDeleteResources()); + return this; + } + + /** + *

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

+ */ + @JsonSetter(value = "delete_resources", nulls = Nulls.SKIP) + public Builder deleteResources(Optional deleteResources) { + this.deleteResources = deleteResources; + return this; + } + + public Builder deleteResources(Boolean deleteResources) { + this.deleteResources = Optional.ofNullable(deleteResources); + return this; + } + + public DeleteProjectRequest build() { + return new DeleteProjectRequest(deleteResources, 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/requests/GetProjectOverviewRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectOverviewRequest.java new file mode 100644 index 0000000..7a9d875 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectOverviewRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetProjectOverviewRequest.Builder.class) +public final class GetProjectOverviewRequest { + private final Map additionalProperties; + + private GetProjectOverviewRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetProjectOverviewRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetProjectOverviewRequest other) { + return this; + } + + public GetProjectOverviewRequest build() { + return new GetProjectOverviewRequest(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/requests/GetProjectRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectRequest.java new file mode 100644 index 0000000..90cb26c --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/GetProjectRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetProjectRequest.Builder.class) +public final class GetProjectRequest { + private final Map additionalProperties; + + private GetProjectRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetProjectRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetProjectRequest other) { + return this; + } + + public GetProjectRequest build() { + return new GetProjectRequest(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/requests/ListProjectResourcesRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectResourcesRequest.java new file mode 100644 index 0000000..6f6b71c --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectResourcesRequest.java @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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 com.newscatcher.catchall.types.ProjectResourceType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListProjectResourcesRequest.Builder.class) +public final class ListProjectResourcesRequest { + private final Optional resourceType; + + private final Optional page; + + private final Optional pageSize; + + private final Map additionalProperties; + + private ListProjectResourcesRequest( + Optional resourceType, + Optional page, + Optional pageSize, + Map additionalProperties) { + this.resourceType = resourceType; + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resource_type") + public Optional getResourceType() { + return resourceType; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of records 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 ListProjectResourcesRequest && equalTo((ListProjectResourcesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListProjectResourcesRequest other) { + return resourceType.equals(other.resourceType) && page.equals(other.page) && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, 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 resourceType = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListProjectResourcesRequest other) { + resourceType(other.getResourceType()); + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "resource_type", nulls = Nulls.SKIP) + public Builder resourceType(Optional resourceType) { + this.resourceType = resourceType; + return this; + } + + public Builder resourceType(ProjectResourceType resourceType) { + this.resourceType = Optional.ofNullable(resourceType); + 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 records 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 ListProjectResourcesRequest build() { + return new ListProjectResourcesRequest(resourceType, 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/projects/requests/ListProjectsRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectsRequest.java new file mode 100644 index 0000000..726c0d7 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/ListProjectsRequest.java @@ -0,0 +1,198 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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 com.newscatcher.catchall.types.OwnershipFilter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListProjectsRequest.Builder.class) +public final class ListProjectsRequest { + private final Optional page; + + private final Optional pageSize; + + private final Optional search; + + private final Optional ownership; + + private final Map additionalProperties; + + private ListProjectsRequest( + Optional page, + Optional pageSize, + Optional search, + Optional ownership, + Map additionalProperties) { + this.page = page; + this.pageSize = pageSize; + this.search = search; + this.ownership = ownership; + this.additionalProperties = additionalProperties; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of records per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Filter by project name (case-insensitive substring match). + */ + @JsonProperty("search") + public Optional getSearch() { + return search; + } + + @JsonProperty("ownership") + public Optional getOwnership() { + return ownership; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListProjectsRequest && equalTo((ListProjectsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListProjectsRequest other) { + return page.equals(other.page) + && pageSize.equals(other.pageSize) + && search.equals(other.search) + && ownership.equals(other.ownership); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.pageSize, this.search, this.ownership); + } + + @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(); + + private Optional search = Optional.empty(); + + private Optional ownership = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListProjectsRequest other) { + page(other.getPage()); + pageSize(other.getPageSize()); + search(other.getSearch()); + ownership(other.getOwnership()); + 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 records 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; + } + + /** + *

Filter by project name (case-insensitive substring match).

+ */ + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public Builder search(Optional search) { + this.search = search; + return this; + } + + public Builder search(String search) { + this.search = Optional.ofNullable(search); + return this; + } + + @JsonSetter(value = "ownership", nulls = Nulls.SKIP) + public Builder ownership(Optional ownership) { + this.ownership = ownership; + return this; + } + + public Builder ownership(OwnershipFilter ownership) { + this.ownership = Optional.ofNullable(ownership); + return this; + } + + public ListProjectsRequest build() { + return new ListProjectsRequest(page, pageSize, search, ownership, 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/requests/RemoveResourceFromProjectRequest.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/RemoveResourceFromProjectRequest.java new file mode 100644 index 0000000..714f061 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/RemoveResourceFromProjectRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RemoveResourceFromProjectRequest.Builder.class) +public final class RemoveResourceFromProjectRequest { + private final Map additionalProperties; + + private RemoveResourceFromProjectRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RemoveResourceFromProjectRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RemoveResourceFromProjectRequest other) { + return this; + } + + public RemoveResourceFromProjectRequest build() { + return new RemoveResourceFromProjectRequest(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/requests/UpdateProjectRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/projects/requests/UpdateProjectRequestDto.java new file mode 100644 index 0000000..215c005 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/projects/requests/UpdateProjectRequestDto.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.projects.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 = UpdateProjectRequestDto.Builder.class) +public final class UpdateProjectRequestDto { + private final Optional name; + + private final Optional description; + + private final Map additionalProperties; + + private UpdateProjectRequestDto( + Optional name, Optional description, Map additionalProperties) { + this.name = name; + this.description = description; + this.additionalProperties = additionalProperties; + } + + /** + * @return New name for the project. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return New description for the project. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateProjectRequestDto && equalTo((UpdateProjectRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateProjectRequestDto other) { + return name.equals(other.name) && description.equals(other.description); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description); + } + + @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 name = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateProjectRequestDto other) { + name(other.getName()); + description(other.getDescription()); + return this; + } + + /** + *

New name for the project.

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

New description for the project.

+ */ + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + public UpdateProjectRequestDto build() { + return new UpdateProjectRequestDto(name, description, 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/webhooks/AsyncRawWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java new file mode 100644 index 0000000..29f3dd8 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncRawWebhooksClient.java @@ -0,0 +1,1209 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.newscatcher.catchall.core.CatchAllApiApiException; +import com.newscatcher.catchall.core.CatchAllApiException; +import com.newscatcher.catchall.core.CatchAllApiHttpResponse; +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.MediaTypes; +import com.newscatcher.catchall.core.ObjectMappers; +import com.newscatcher.catchall.core.QueryStringMapper; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.errors.BadRequestError; +import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.NotFoundError; +import com.newscatcher.catchall.errors.UnprocessableEntityError; +import com.newscatcher.catchall.resources.webhooks.requests.AssignWebhookResourceRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.DeleteWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookDeliveryHistoryRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhookResourcesRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksForResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksRequest; +import com.newscatcher.catchall.resources.webhooks.requests.RemoveWebhookResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.TestWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.UpdateWebhookRequestDto; +import com.newscatcher.catchall.types.AssignWebhookResourceResponseDto; +import com.newscatcher.catchall.types.CreateWebhookResponseDto; +import com.newscatcher.catchall.types.DeliveryHistoryResponseDto; +import com.newscatcher.catchall.types.Error; +import com.newscatcher.catchall.types.GetWebhookResponseDto; +import com.newscatcher.catchall.types.ListWebhookResourcesResponseDto; +import com.newscatcher.catchall.types.ListWebhooksResponseDto; +import com.newscatcher.catchall.types.MappableResourceType; +import com.newscatcher.catchall.types.TestWebhookResponseDto; +import com.newscatcher.catchall.types.UpdateWebhookResponseDto; +import com.newscatcher.catchall.types.ValidationErrorResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhooksClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture> listWebhooks() { + return listWebhooks(ListWebhooksRequest.builder().build()); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture> listWebhooks( + RequestOptions requestOptions) { + return listWebhooks(ListWebhooksRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture> listWebhooks( + ListWebhooksRequest request) { + return listWebhooks(request, null); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture> listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks"); + 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 (request.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "search", request.getSearch().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); + } + 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, ListWebhooksResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 403: + future.completeExceptionally(new ForbiddenError( + 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 (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; + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CompletableFuture> createWebhook( + CreateWebhookRequestDto request) { + return createWebhook(request, null); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CompletableFuture> createWebhook( + CreateWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, CreateWebhookResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 403: + future.completeExceptionally(new ForbiddenError( + 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 (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; + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture> getWebhook(String webhookId) { + return getWebhook(webhookId, GetWebhookRequest.builder().build()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture> getWebhook( + String webhookId, RequestOptions requestOptions) { + return getWebhook(webhookId, GetWebhookRequest.builder().build(), requestOptions); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture> getWebhook( + String webhookId, GetWebhookRequest request) { + return getWebhook(webhookId, request, null); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture> getWebhook( + String webhookId, GetWebhookRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + 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); + } + 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, GetWebhookResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * 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.

+ */ + public CompletableFuture> deleteWebhook(String webhookId) { + return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build()); + } + + /** + * 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.

+ */ + public CompletableFuture> deleteWebhook( + String webhookId, RequestOptions requestOptions) { + return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build(), 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.

+ */ + public CompletableFuture> deleteWebhook( + String webhookId, DeleteWebhookRequest request) { + return deleteWebhook(webhookId, request, null); + } + + /** + * 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.

+ */ + public CompletableFuture> deleteWebhook( + String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + 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()) { + if (response.isSuccessful()) { + future.complete(new CatchAllApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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; + } + } 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 (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; + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture> updateWebhook(String webhookId) { + return updateWebhook(webhookId, UpdateWebhookRequestDto.builder().build()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture> updateWebhook( + String webhookId, RequestOptions requestOptions) { + return updateWebhook(webhookId, UpdateWebhookRequestDto.builder().build(), requestOptions); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture> updateWebhook( + String webhookId, UpdateWebhookRequestDto request) { + return updateWebhook(webhookId, request, null); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture> updateWebhook( + String webhookId, UpdateWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, UpdateWebhookResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * 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.

+ */ + public CompletableFuture> testWebhook(String webhookId) { + return testWebhook(webhookId, TestWebhookRequestDto.builder().build()); + } + + /** + * 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.

+ */ + public CompletableFuture> testWebhook( + String webhookId, RequestOptions requestOptions) { + return testWebhook(webhookId, TestWebhookRequestDto.builder().build(), requestOptions); + } + + /** + * 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.

+ */ + public CompletableFuture> testWebhook( + String webhookId, TestWebhookRequestDto request) { + return testWebhook(webhookId, request, null); + } + + /** + * 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.

+ */ + public CompletableFuture> testWebhook( + String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("test"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, TestWebhookResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture> listWebhookResources( + String webhookId) { + return listWebhookResources( + webhookId, ListWebhookResourcesRequest.builder().build()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture> listWebhookResources( + String webhookId, RequestOptions requestOptions) { + return listWebhookResources( + webhookId, ListWebhookResourcesRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture> listWebhookResources( + String webhookId, ListWebhookResourcesRequest request) { + return listWebhookResources(webhookId, request, null); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture> listWebhookResources( + String webhookId, ListWebhookResourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources"); + if (request.getResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "resource_type", request.getResourceType().get(), false); + } + 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); + } + 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, ListWebhookResourcesResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CompletableFuture> assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request) { + return assignWebhookResource(webhookId, request, null); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CompletableFuture> assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, AssignWebhookResourceResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture> removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId) { + return removeWebhookResource( + webhookId, + resourceType, + resourceId, + RemoveWebhookResourceRequest.builder().build()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture> removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return removeWebhookResource( + webhookId, + resourceType, + resourceId, + RemoveWebhookResourceRequest.builder().build(), + requestOptions); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture> removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request) { + return removeWebhookResource(webhookId, resourceType, resourceId, request, null); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture> removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + 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()) { + if (response.isSuccessful()) { + future.complete(new CatchAllApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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; + } + } 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 (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; + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture> listWebhooksForResource( + MappableResourceType resourceType, String resourceId) { + return listWebhooksForResource( + resourceType, + resourceId, + ListWebhooksForResourceRequest.builder().build()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture> listWebhooksForResource( + MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return listWebhooksForResource( + resourceType, + resourceId, + ListWebhooksForResourceRequest.builder().build(), + requestOptions); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture> listWebhooksForResource( + MappableResourceType resourceType, String resourceId, ListWebhooksForResourceRequest request) { + return listWebhooksForResource(resourceType, resourceId, request, null); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture> listWebhooksForResource( + MappableResourceType resourceType, + String resourceId, + ListWebhooksForResourceRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId) + .addPathSegments("webhooks"); + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + 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); + } + 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, ListWebhooksResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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; + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CompletableFuture> getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request) { + return getWebhookDeliveryHistory(request, null); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CompletableFuture> getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhook-history"); + QueryStringMapper.addQueryParameter(httpUrl, "resource_type", request.getResourceType(), false); + QueryStringMapper.addQueryParameter(httpUrl, "resource_id", request.getResourceId(), false); + 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); + } + 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, DeliveryHistoryResponseDto.class), + response)); + return; + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } 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/webhooks/AsyncWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java new file mode 100644 index 0000000..77913f9 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/AsyncWebhooksClient.java @@ -0,0 +1,382 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks; + +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.resources.webhooks.requests.AssignWebhookResourceRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.DeleteWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookDeliveryHistoryRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhookResourcesRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksForResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksRequest; +import com.newscatcher.catchall.resources.webhooks.requests.RemoveWebhookResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.TestWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.UpdateWebhookRequestDto; +import com.newscatcher.catchall.types.AssignWebhookResourceResponseDto; +import com.newscatcher.catchall.types.CreateWebhookResponseDto; +import com.newscatcher.catchall.types.DeliveryHistoryResponseDto; +import com.newscatcher.catchall.types.GetWebhookResponseDto; +import com.newscatcher.catchall.types.ListWebhookResourcesResponseDto; +import com.newscatcher.catchall.types.ListWebhooksResponseDto; +import com.newscatcher.catchall.types.MappableResourceType; +import com.newscatcher.catchall.types.TestWebhookResponseDto; +import com.newscatcher.catchall.types.UpdateWebhookResponseDto; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhooksClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhooksClient rawClient; + + public AsyncWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhooksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhooksClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture listWebhooks() { + return this.rawClient.listWebhooks().thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture listWebhooks(RequestOptions requestOptions) { + return this.rawClient.listWebhooks(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture listWebhooks(ListWebhooksRequest request) { + return this.rawClient.listWebhooks(request).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CompletableFuture listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + return this.rawClient.listWebhooks(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CompletableFuture createWebhook(CreateWebhookRequestDto request) { + return this.rawClient.createWebhook(request).thenApply(response -> response.body()); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CompletableFuture createWebhook( + CreateWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.createWebhook(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture getWebhook(String webhookId) { + return this.rawClient.getWebhook(webhookId).thenApply(response -> response.body()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture getWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.getWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture getWebhook(String webhookId, GetWebhookRequest request) { + return this.rawClient.getWebhook(webhookId, request).thenApply(response -> response.body()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CompletableFuture getWebhook( + String webhookId, GetWebhookRequest request, RequestOptions requestOptions) { + return this.rawClient.getWebhook(webhookId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture deleteWebhook(String webhookId) { + return this.rawClient.deleteWebhook(webhookId).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture deleteWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.deleteWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture deleteWebhook(String webhookId, DeleteWebhookRequest request) { + return this.rawClient.deleteWebhook(webhookId, request).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture deleteWebhook( + String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteWebhook(webhookId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture updateWebhook(String webhookId) { + return this.rawClient.updateWebhook(webhookId).thenApply(response -> response.body()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture updateWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.updateWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture updateWebhook( + String webhookId, UpdateWebhookRequestDto request) { + return this.rawClient.updateWebhook(webhookId, request).thenApply(response -> response.body()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CompletableFuture updateWebhook( + String webhookId, UpdateWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.updateWebhook(webhookId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture testWebhook(String webhookId) { + return this.rawClient.testWebhook(webhookId).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture testWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.testWebhook(webhookId, requestOptions).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture testWebhook(String webhookId, TestWebhookRequestDto request) { + return this.rawClient.testWebhook(webhookId, request).thenApply(response -> response.body()); + } + + /** + * 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.

+ */ + public CompletableFuture testWebhook( + String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.testWebhook(webhookId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture listWebhookResources(String webhookId) { + return this.rawClient.listWebhookResources(webhookId).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture listWebhookResources( + String webhookId, RequestOptions requestOptions) { + return this.rawClient.listWebhookResources(webhookId, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture listWebhookResources( + String webhookId, ListWebhookResourcesRequest request) { + return this.rawClient.listWebhookResources(webhookId, request).thenApply(response -> response.body()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CompletableFuture listWebhookResources( + String webhookId, ListWebhookResourcesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listWebhookResources(webhookId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CompletableFuture assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request) { + return this.rawClient.assignWebhookResource(webhookId, request).thenApply(response -> response.body()); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CompletableFuture assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request, RequestOptions requestOptions) { + return this.rawClient + .assignWebhookResource(webhookId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId) { + return this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId) + .thenApply(response -> response.body()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request) { + return this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, request) + .thenApply(response -> response.body()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CompletableFuture removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request, + RequestOptions requestOptions) { + return this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture listWebhooksForResource( + MappableResourceType resourceType, String resourceId) { + return this.rawClient.listWebhooksForResource(resourceType, resourceId).thenApply(response -> response.body()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture listWebhooksForResource( + MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture listWebhooksForResource( + MappableResourceType resourceType, String resourceId, ListWebhooksForResourceRequest request) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, request) + .thenApply(response -> response.body()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CompletableFuture listWebhooksForResource( + MappableResourceType resourceType, + String resourceId, + ListWebhooksForResourceRequest request, + RequestOptions requestOptions) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CompletableFuture getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request) { + return this.rawClient.getWebhookDeliveryHistory(request).thenApply(response -> response.body()); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CompletableFuture getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request, RequestOptions requestOptions) { + return this.rawClient.getWebhookDeliveryHistory(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java new file mode 100644 index 0000000..981eab6 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/RawWebhooksClient.java @@ -0,0 +1,990 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.newscatcher.catchall.core.CatchAllApiApiException; +import com.newscatcher.catchall.core.CatchAllApiException; +import com.newscatcher.catchall.core.CatchAllApiHttpResponse; +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.MediaTypes; +import com.newscatcher.catchall.core.ObjectMappers; +import com.newscatcher.catchall.core.QueryStringMapper; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.errors.BadRequestError; +import com.newscatcher.catchall.errors.ForbiddenError; +import com.newscatcher.catchall.errors.NotFoundError; +import com.newscatcher.catchall.errors.UnprocessableEntityError; +import com.newscatcher.catchall.resources.webhooks.requests.AssignWebhookResourceRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.DeleteWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookDeliveryHistoryRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhookResourcesRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksForResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksRequest; +import com.newscatcher.catchall.resources.webhooks.requests.RemoveWebhookResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.TestWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.UpdateWebhookRequestDto; +import com.newscatcher.catchall.types.AssignWebhookResourceResponseDto; +import com.newscatcher.catchall.types.CreateWebhookResponseDto; +import com.newscatcher.catchall.types.DeliveryHistoryResponseDto; +import com.newscatcher.catchall.types.Error; +import com.newscatcher.catchall.types.GetWebhookResponseDto; +import com.newscatcher.catchall.types.ListWebhookResourcesResponseDto; +import com.newscatcher.catchall.types.ListWebhooksResponseDto; +import com.newscatcher.catchall.types.MappableResourceType; +import com.newscatcher.catchall.types.TestWebhookResponseDto; +import com.newscatcher.catchall.types.UpdateWebhookResponseDto; +import com.newscatcher.catchall.types.ValidationErrorResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhooksClient { + protected final ClientOptions clientOptions; + + public RawWebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CatchAllApiHttpResponse listWebhooks() { + return listWebhooks(ListWebhooksRequest.builder().build()); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CatchAllApiHttpResponse listWebhooks(RequestOptions requestOptions) { + return listWebhooks(ListWebhooksRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CatchAllApiHttpResponse listWebhooks(ListWebhooksRequest request) { + return listWebhooks(request, null); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public CatchAllApiHttpResponse listWebhooks( + ListWebhooksRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks"); + 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 (request.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "search", request.getSearch().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); + } + 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, ListWebhooksResponseDto.class), + response); + } + try { + switch (response.code()) { + case 403: + throw new ForbiddenError( + 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CatchAllApiHttpResponse createWebhook(CreateWebhookRequestDto request) { + return createWebhook(request, null); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CatchAllApiHttpResponse createWebhook( + CreateWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, CreateWebhookResponseDto.class), + response); + } + try { + switch (response.code()) { + case 403: + throw new ForbiddenError( + 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CatchAllApiHttpResponse getWebhook(String webhookId) { + return getWebhook(webhookId, GetWebhookRequest.builder().build()); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CatchAllApiHttpResponse getWebhook(String webhookId, RequestOptions requestOptions) { + return getWebhook(webhookId, GetWebhookRequest.builder().build(), requestOptions); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CatchAllApiHttpResponse getWebhook(String webhookId, GetWebhookRequest request) { + return getWebhook(webhookId, request, null); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public CatchAllApiHttpResponse getWebhook( + String webhookId, GetWebhookRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + 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); + } + 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, GetWebhookResponseDto.class), response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", 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.

+ */ + public CatchAllApiHttpResponse deleteWebhook(String webhookId) { + return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build()); + } + + /** + * 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.

+ */ + public CatchAllApiHttpResponse deleteWebhook(String webhookId, RequestOptions requestOptions) { + return deleteWebhook(webhookId, DeleteWebhookRequest.builder().build(), 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.

+ */ + public CatchAllApiHttpResponse deleteWebhook(String webhookId, DeleteWebhookRequest request) { + return deleteWebhook(webhookId, request, null); + } + + /** + * 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.

+ */ + public CatchAllApiHttpResponse deleteWebhook( + String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new CatchAllApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CatchAllApiHttpResponse updateWebhook(String webhookId) { + return updateWebhook(webhookId, UpdateWebhookRequestDto.builder().build()); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CatchAllApiHttpResponse updateWebhook( + String webhookId, RequestOptions requestOptions) { + return updateWebhook(webhookId, UpdateWebhookRequestDto.builder().build(), requestOptions); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CatchAllApiHttpResponse updateWebhook( + String webhookId, UpdateWebhookRequestDto request) { + return updateWebhook(webhookId, request, null); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public CatchAllApiHttpResponse updateWebhook( + String webhookId, UpdateWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, UpdateWebhookResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", 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.

+ */ + public CatchAllApiHttpResponse testWebhook(String webhookId) { + return testWebhook(webhookId, TestWebhookRequestDto.builder().build()); + } + + /** + * 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.

+ */ + public CatchAllApiHttpResponse testWebhook( + String webhookId, RequestOptions requestOptions) { + return testWebhook(webhookId, TestWebhookRequestDto.builder().build(), requestOptions); + } + + /** + * 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.

+ */ + public CatchAllApiHttpResponse testWebhook( + String webhookId, TestWebhookRequestDto request) { + return testWebhook(webhookId, request, null); + } + + /** + * 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.

+ */ + public CatchAllApiHttpResponse testWebhook( + String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("test"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, TestWebhookResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CatchAllApiHttpResponse listWebhookResources(String webhookId) { + return listWebhookResources( + webhookId, ListWebhookResourcesRequest.builder().build()); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CatchAllApiHttpResponse listWebhookResources( + String webhookId, RequestOptions requestOptions) { + return listWebhookResources( + webhookId, ListWebhookResourcesRequest.builder().build(), requestOptions); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CatchAllApiHttpResponse listWebhookResources( + String webhookId, ListWebhookResourcesRequest request) { + return listWebhookResources(webhookId, request, null); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public CatchAllApiHttpResponse listWebhookResources( + String webhookId, ListWebhookResourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources"); + if (request.getResourceType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "resource_type", request.getResourceType().get(), false); + } + 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); + } + 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, ListWebhookResourcesResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CatchAllApiHttpResponse assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request) { + return assignWebhookResource(webhookId, request, null); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public CatchAllApiHttpResponse assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new CatchAllApiException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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, AssignWebhookResourceResponseDto.class), + response); + } + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CatchAllApiHttpResponse removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId) { + return removeWebhookResource( + webhookId, + resourceType, + resourceId, + RemoveWebhookResourceRequest.builder().build()); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CatchAllApiHttpResponse removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return removeWebhookResource( + webhookId, + resourceType, + resourceId, + RemoveWebhookResourceRequest.builder().build(), + requestOptions); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CatchAllApiHttpResponse removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request) { + return removeWebhookResource(webhookId, resourceType, resourceId, request, null); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public CatchAllApiHttpResponse removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhooks") + .addPathSegment(webhookId) + .addPathSegments("resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", 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); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new CatchAllApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + 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); + } + } 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 (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CatchAllApiHttpResponse listWebhooksForResource( + MappableResourceType resourceType, String resourceId) { + return listWebhooksForResource( + resourceType, + resourceId, + ListWebhooksForResourceRequest.builder().build()); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CatchAllApiHttpResponse listWebhooksForResource( + MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return listWebhooksForResource( + resourceType, + resourceId, + ListWebhooksForResourceRequest.builder().build(), + requestOptions); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CatchAllApiHttpResponse listWebhooksForResource( + MappableResourceType resourceType, String resourceId, ListWebhooksForResourceRequest request) { + return listWebhooksForResource(resourceType, resourceId, request, null); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public CatchAllApiHttpResponse listWebhooksForResource( + MappableResourceType resourceType, + String resourceId, + ListWebhooksForResourceRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/resources") + .addPathSegment(resourceType.toString()) + .addPathSegment(resourceId) + .addPathSegments("webhooks"); + if (request.getIsActive().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_active", request.getIsActive().get(), false); + } + 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); + } + 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, ListWebhooksResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CatchAllApiHttpResponse getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request) { + return getWebhookDeliveryHistory(request, null); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public CatchAllApiHttpResponse getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("catchAll/webhook-history"); + QueryStringMapper.addQueryParameter(httpUrl, "resource_type", request.getResourceType(), false); + QueryStringMapper.addQueryParameter(httpUrl, "resource_id", request.getResourceId(), false); + 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); + } + 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, DeliveryHistoryResponseDto.class), + response); + } + try { + switch (response.code()) { + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new CatchAllApiApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new CatchAllApiException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java new file mode 100644 index 0000000..8e70c31 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/WebhooksClient.java @@ -0,0 +1,372 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks; + +import com.newscatcher.catchall.core.ClientOptions; +import com.newscatcher.catchall.core.RequestOptions; +import com.newscatcher.catchall.resources.webhooks.requests.AssignWebhookResourceRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.CreateWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.DeleteWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookDeliveryHistoryRequest; +import com.newscatcher.catchall.resources.webhooks.requests.GetWebhookRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhookResourcesRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksForResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.ListWebhooksRequest; +import com.newscatcher.catchall.resources.webhooks.requests.RemoveWebhookResourceRequest; +import com.newscatcher.catchall.resources.webhooks.requests.TestWebhookRequestDto; +import com.newscatcher.catchall.resources.webhooks.requests.UpdateWebhookRequestDto; +import com.newscatcher.catchall.types.AssignWebhookResourceResponseDto; +import com.newscatcher.catchall.types.CreateWebhookResponseDto; +import com.newscatcher.catchall.types.DeliveryHistoryResponseDto; +import com.newscatcher.catchall.types.GetWebhookResponseDto; +import com.newscatcher.catchall.types.ListWebhookResourcesResponseDto; +import com.newscatcher.catchall.types.ListWebhooksResponseDto; +import com.newscatcher.catchall.types.MappableResourceType; +import com.newscatcher.catchall.types.TestWebhookResponseDto; +import com.newscatcher.catchall.types.UpdateWebhookResponseDto; + +public class WebhooksClient { + protected final ClientOptions clientOptions; + + private final RawWebhooksClient rawClient; + + public WebhooksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawWebhooksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhooksClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public ListWebhooksResponseDto listWebhooks() { + return this.rawClient.listWebhooks().body(); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public ListWebhooksResponseDto listWebhooks(RequestOptions requestOptions) { + return this.rawClient.listWebhooks(requestOptions).body(); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public ListWebhooksResponseDto listWebhooks(ListWebhooksRequest request) { + return this.rawClient.listWebhooks(request).body(); + } + + /** + * Returns a paginated list of webhooks belonging to the organization. + */ + public ListWebhooksResponseDto listWebhooks(ListWebhooksRequest request, RequestOptions requestOptions) { + return this.rawClient.listWebhooks(request, requestOptions).body(); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CreateWebhookResponseDto createWebhook(CreateWebhookRequestDto request) { + return this.rawClient.createWebhook(request).body(); + } + + /** + * Creates a new webhook endpoint for the organization. + */ + public CreateWebhookResponseDto createWebhook(CreateWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.createWebhook(request, requestOptions).body(); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public GetWebhookResponseDto getWebhook(String webhookId) { + return this.rawClient.getWebhook(webhookId).body(); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public GetWebhookResponseDto getWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.getWebhook(webhookId, requestOptions).body(); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public GetWebhookResponseDto getWebhook(String webhookId, GetWebhookRequest request) { + return this.rawClient.getWebhook(webhookId, request).body(); + } + + /** + * Returns the full configuration of a single webhook by ID. + */ + public GetWebhookResponseDto getWebhook( + String webhookId, GetWebhookRequest request, RequestOptions requestOptions) { + return this.rawClient.getWebhook(webhookId, request, requestOptions).body(); + } + + /** + * 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.

+ */ + public void deleteWebhook(String webhookId) { + this.rawClient.deleteWebhook(webhookId).body(); + } + + /** + * 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.

+ */ + public void deleteWebhook(String webhookId, RequestOptions requestOptions) { + this.rawClient.deleteWebhook(webhookId, requestOptions).body(); + } + + /** + * 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.

+ */ + public void deleteWebhook(String webhookId, DeleteWebhookRequest request) { + this.rawClient.deleteWebhook(webhookId, request).body(); + } + + /** + * 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.

+ */ + public void deleteWebhook(String webhookId, DeleteWebhookRequest request, RequestOptions requestOptions) { + this.rawClient.deleteWebhook(webhookId, request, requestOptions).body(); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public UpdateWebhookResponseDto updateWebhook(String webhookId) { + return this.rawClient.updateWebhook(webhookId).body(); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public UpdateWebhookResponseDto updateWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.updateWebhook(webhookId, requestOptions).body(); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public UpdateWebhookResponseDto updateWebhook(String webhookId, UpdateWebhookRequestDto request) { + return this.rawClient.updateWebhook(webhookId, request).body(); + } + + /** + * Updates one or more fields of an existing webhook. + */ + public UpdateWebhookResponseDto updateWebhook( + String webhookId, UpdateWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.updateWebhook(webhookId, request, requestOptions).body(); + } + + /** + * 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.

+ */ + public TestWebhookResponseDto testWebhook(String webhookId) { + return this.rawClient.testWebhook(webhookId).body(); + } + + /** + * 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.

+ */ + public TestWebhookResponseDto testWebhook(String webhookId, RequestOptions requestOptions) { + return this.rawClient.testWebhook(webhookId, requestOptions).body(); + } + + /** + * 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.

+ */ + public TestWebhookResponseDto testWebhook(String webhookId, TestWebhookRequestDto request) { + return this.rawClient.testWebhook(webhookId, request).body(); + } + + /** + * 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.

+ */ + public TestWebhookResponseDto testWebhook( + String webhookId, TestWebhookRequestDto request, RequestOptions requestOptions) { + return this.rawClient.testWebhook(webhookId, request, requestOptions).body(); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public ListWebhookResourcesResponseDto listWebhookResources(String webhookId) { + return this.rawClient.listWebhookResources(webhookId).body(); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public ListWebhookResourcesResponseDto listWebhookResources(String webhookId, RequestOptions requestOptions) { + return this.rawClient.listWebhookResources(webhookId, requestOptions).body(); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public ListWebhookResourcesResponseDto listWebhookResources(String webhookId, ListWebhookResourcesRequest request) { + return this.rawClient.listWebhookResources(webhookId, request).body(); + } + + /** + * Returns a paginated list of resources currently assigned to this webhook. + */ + public ListWebhookResourcesResponseDto listWebhookResources( + String webhookId, ListWebhookResourcesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listWebhookResources(webhookId, request, requestOptions) + .body(); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public AssignWebhookResourceResponseDto assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request) { + return this.rawClient.assignWebhookResource(webhookId, request).body(); + } + + /** + * Attaches a job, monitor, or 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.

+ */ + public AssignWebhookResourceResponseDto assignWebhookResource( + String webhookId, AssignWebhookResourceRequestDto request, RequestOptions requestOptions) { + return this.rawClient + .assignWebhookResource(webhookId, request, requestOptions) + .body(); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public void removeWebhookResource(String webhookId, MappableResourceType resourceType, String resourceId) { + this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId) + .body(); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public void removeWebhookResource( + String webhookId, MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, requestOptions) + .body(); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public void removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request) { + this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, request) + .body(); + } + + /** + * Detaches a resource from this webhook. Completions of the resource no longer trigger delivery to this webhook. + *

The webhook and the resource itself are not deleted.

+ */ + public void removeWebhookResource( + String webhookId, + MappableResourceType resourceType, + String resourceId, + RemoveWebhookResourceRequest request, + RequestOptions requestOptions) { + this.rawClient + .removeWebhookResource(webhookId, resourceType, resourceId, request, requestOptions) + .body(); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public ListWebhooksResponseDto listWebhooksForResource(MappableResourceType resourceType, String resourceId) { + return this.rawClient.listWebhooksForResource(resourceType, resourceId).body(); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public ListWebhooksResponseDto listWebhooksForResource( + MappableResourceType resourceType, String resourceId, RequestOptions requestOptions) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, requestOptions) + .body(); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public ListWebhooksResponseDto listWebhooksForResource( + MappableResourceType resourceType, String resourceId, ListWebhooksForResourceRequest request) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, request) + .body(); + } + + /** + * Returns all webhooks currently assigned to the given resource. + */ + public ListWebhooksResponseDto listWebhooksForResource( + MappableResourceType resourceType, + String resourceId, + ListWebhooksForResourceRequest request, + RequestOptions requestOptions) { + return this.rawClient + .listWebhooksForResource(resourceType, resourceId, request, requestOptions) + .body(); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public DeliveryHistoryResponseDto getWebhookDeliveryHistory(GetWebhookDeliveryHistoryRequest request) { + return this.rawClient.getWebhookDeliveryHistory(request).body(); + } + + /** + * Returns a paginated delivery log for a given resource, ordered by timestamp descending. + *

Each record shows the webhook dispatched, the HTTP status code returned, delivery outcome, and any error or warning messages. Use this to debug failed deliveries or audit dispatch activity.

+ */ + public DeliveryHistoryResponseDto getWebhookDeliveryHistory( + GetWebhookDeliveryHistoryRequest request, RequestOptions requestOptions) { + return this.rawClient.getWebhookDeliveryHistory(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/AssignWebhookResourceRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/AssignWebhookResourceRequestDto.java new file mode 100644 index 0000000..0126f88 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/AssignWebhookResourceRequestDto.java @@ -0,0 +1,164 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import com.newscatcher.catchall.types.MappableResourceType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AssignWebhookResourceRequestDto.Builder.class) +public final class AssignWebhookResourceRequestDto { + private final MappableResourceType resourceType; + + private final String resourceId; + + private final Map additionalProperties; + + private AssignWebhookResourceRequestDto( + MappableResourceType resourceType, String resourceId, Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of resource to assign. + */ + @JsonProperty("resource_type") + public MappableResourceType getResourceType() { + return resourceType; + } + + /** + * @return ID of the resource to assign. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AssignWebhookResourceRequestDto && equalTo((AssignWebhookResourceRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AssignWebhookResourceRequestDto other) { + return resourceType.equals(other.resourceType) && resourceId.equals(other.resourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.resourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + /** + *

Type of resource to assign.

+ */ + ResourceIdStage resourceType(@NotNull MappableResourceType resourceType); + + Builder from(AssignWebhookResourceRequestDto other); + } + + public interface ResourceIdStage { + /** + *

ID of the resource to assign.

+ */ + _FinalStage resourceId(@NotNull String resourceId); + } + + public interface _FinalStage { + AssignWebhookResourceRequestDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ResourceTypeStage, ResourceIdStage, _FinalStage { + private MappableResourceType resourceType; + + private String resourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AssignWebhookResourceRequestDto other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + return this; + } + + /** + *

Type of resource to assign.

+ *

Type of resource to assign.

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

ID of the resource to assign.

+ *

ID of the resource to assign.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("resource_id") + public _FinalStage resourceId(@NotNull String resourceId) { + this.resourceId = Objects.requireNonNull(resourceId, "resourceId must not be null"); + return this; + } + + @java.lang.Override + public AssignWebhookResourceRequestDto build() { + return new AssignWebhookResourceRequestDto(resourceType, resourceId, 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/resources/webhooks/requests/CreateWebhookRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/CreateWebhookRequestDto.java new file mode 100644 index 0000000..355c301 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/CreateWebhookRequestDto.java @@ -0,0 +1,535 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 com.newscatcher.catchall.resources.webhooks.types.CreateWebhookRequestDtoAuth; +import com.newscatcher.catchall.types.DeliveryMode; +import com.newscatcher.catchall.types.HttpMethod; +import com.newscatcher.catchall.types.WebhookType; +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 = CreateWebhookRequestDto.Builder.class) +public final class CreateWebhookRequestDto { + private final String name; + + private final String url; + + private final Optional type; + + private final Optional deliveryMode; + + private final Optional method; + + private final Optional> headers; + + private final Optional> params; + + private final Optional auth; + + private final Optional> formatterConfig; + + private final Map additionalProperties; + + private CreateWebhookRequestDto( + String name, + String url, + Optional type, + Optional deliveryMode, + Optional method, + Optional> headers, + Optional> params, + Optional auth, + Optional> formatterConfig, + Map additionalProperties) { + this.name = name; + this.url = url; + this.type = type; + this.deliveryMode = deliveryMode; + this.method = method; + this.headers = headers; + this.params = params; + this.auth = auth; + this.formatterConfig = formatterConfig; + this.additionalProperties = additionalProperties; + } + + /** + * @return Human-readable label for this webhook. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Destination URL that receives the payload. Must use HTTPS. IP addresses are not accepted. + *

Type-specific URL requirements:

+ *
    + *
  • slack: Must start with https://hooks.slack.com/.
  • + *
  • teams: Hostname must match *.webhook.office.com or *.webhook.office365.com.
  • + *
  • generic: Any valid HTTPS domain.
  • + *
  • custom: Any valid HTTPS domain.
  • + *
+ *

When type is omitted, it is auto-detected from the URL.

+ */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("delivery_mode") + public Optional getDeliveryMode() { + return deliveryMode; + } + + @JsonProperty("method") + public Optional getMethod() { + return method; + } + + /** + * @return Custom HTTP headers forwarded with each delivery. + */ + @JsonProperty("headers") + public Optional> getHeaders() { + return headers; + } + + /** + * @return Query parameters appended to the webhook URL. + */ + @JsonProperty("params") + public Optional> getParams() { + return params; + } + + /** + * @return Authentication forwarded with each delivery. Supported types: + *
    + *
  • bearer: Adds an Authorization: Bearer <token> header.
  • + *
  • api_key: Adds a custom header with the specified name and value.
  • + *
  • basic: Adds an Authorization: Basic <credentials> header.
  • + *
+ */ + @JsonProperty("auth") + public Optional getAuth() { + return auth; + } + + /** + * @return Custom payload transformation configuration. Required only when type is custom. + */ + @JsonIgnore + public Optional> getFormatterConfig() { + if (formatterConfig == null) { + return Optional.empty(); + } + return formatterConfig; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("formatter_config") + private Optional> _getFormatterConfig() { + return formatterConfig; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateWebhookRequestDto && equalTo((CreateWebhookRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateWebhookRequestDto other) { + return name.equals(other.name) + && url.equals(other.url) + && type.equals(other.type) + && deliveryMode.equals(other.deliveryMode) + && method.equals(other.method) + && headers.equals(other.headers) + && params.equals(other.params) + && auth.equals(other.auth) + && formatterConfig.equals(other.formatterConfig); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.url, + this.type, + this.deliveryMode, + this.method, + this.headers, + this.params, + this.auth, + this.formatterConfig); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + /** + *

Human-readable label for this webhook.

+ */ + UrlStage name(@NotNull String name); + + Builder from(CreateWebhookRequestDto other); + } + + public interface UrlStage { + /** + *

Destination URL that receives the payload. Must use HTTPS. IP addresses are not accepted.

+ *

Type-specific URL requirements:

+ *
    + *
  • slack: Must start with https://hooks.slack.com/.
  • + *
  • teams: Hostname must match *.webhook.office.com or *.webhook.office365.com.
  • + *
  • generic: Any valid HTTPS domain.
  • + *
  • custom: Any valid HTTPS domain.
  • + *
+ *

When type is omitted, it is auto-detected from the URL.

+ */ + _FinalStage url(@NotNull String url); + } + + public interface _FinalStage { + CreateWebhookRequestDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage type(Optional type); + + _FinalStage type(WebhookType type); + + _FinalStage deliveryMode(Optional deliveryMode); + + _FinalStage deliveryMode(DeliveryMode deliveryMode); + + _FinalStage method(Optional method); + + _FinalStage method(HttpMethod method); + + /** + *

Custom HTTP headers forwarded with each delivery.

+ */ + _FinalStage headers(Optional> headers); + + _FinalStage headers(Map headers); + + /** + *

Query parameters appended to the webhook URL.

+ */ + _FinalStage params(Optional> params); + + _FinalStage params(Map params); + + /** + *

Authentication forwarded with each delivery. Supported types:

+ *
    + *
  • bearer: Adds an Authorization: Bearer <token> header.
  • + *
  • api_key: Adds a custom header with the specified name and value.
  • + *
  • basic: Adds an Authorization: Basic <credentials> header.
  • + *
+ */ + _FinalStage auth(Optional auth); + + _FinalStage auth(CreateWebhookRequestDtoAuth auth); + + /** + *

Custom payload transformation configuration. Required only when type is custom.

+ */ + _FinalStage formatterConfig(Optional> formatterConfig); + + _FinalStage formatterConfig(Map formatterConfig); + + _FinalStage formatterConfig(Nullable> formatterConfig); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, UrlStage, _FinalStage { + private String name; + + private String url; + + private Optional> formatterConfig = Optional.empty(); + + private Optional auth = Optional.empty(); + + private Optional> params = Optional.empty(); + + private Optional> headers = Optional.empty(); + + private Optional method = Optional.empty(); + + private Optional deliveryMode = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateWebhookRequestDto other) { + name(other.getName()); + url(other.getUrl()); + type(other.getType()); + deliveryMode(other.getDeliveryMode()); + method(other.getMethod()); + headers(other.getHeaders()); + params(other.getParams()); + auth(other.getAuth()); + formatterConfig(other.getFormatterConfig()); + return this; + } + + /** + *

Human-readable label for this webhook.

+ *

Human-readable label for this webhook.

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

Destination URL that receives the payload. Must use HTTPS. IP addresses are not accepted.

+ *

Type-specific URL requirements:

+ *
    + *
  • slack: Must start with https://hooks.slack.com/.
  • + *
  • teams: Hostname must match *.webhook.office.com or *.webhook.office365.com.
  • + *
  • generic: Any valid HTTPS domain.
  • + *
  • custom: Any valid HTTPS domain.
  • + *
+ *

When type is omitted, it is auto-detected from the URL.

+ *

Destination URL that receives the payload. Must use HTTPS. IP addresses are not accepted.

+ *

Type-specific URL requirements:

+ *
    + *
  • slack: Must start with https://hooks.slack.com/.
  • + *
  • teams: Hostname must match *.webhook.office.com or *.webhook.office365.com.
  • + *
  • generic: Any valid HTTPS domain.
  • + *
  • custom: Any valid HTTPS domain.
  • + *
+ *

When type is omitted, it is auto-detected from the URL.

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

Custom payload transformation configuration. Required only when type is custom.

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

Custom payload transformation configuration. Required only when type is custom.

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

Custom payload transformation configuration. Required only when type is custom.

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

Authentication forwarded with each delivery. Supported types:

+ *
    + *
  • bearer: Adds an Authorization: Bearer <token> header.
  • + *
  • api_key: Adds a custom header with the specified name and value.
  • + *
  • basic: Adds an Authorization: Basic <credentials> header.
  • + *
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage auth(CreateWebhookRequestDtoAuth auth) { + this.auth = Optional.ofNullable(auth); + return this; + } + + /** + *

Authentication forwarded with each delivery. Supported types:

+ *
    + *
  • bearer: Adds an Authorization: Bearer <token> header.
  • + *
  • api_key: Adds a custom header with the specified name and value.
  • + *
  • basic: Adds an Authorization: Basic <credentials> header.
  • + *
+ */ + @java.lang.Override + @JsonSetter(value = "auth", nulls = Nulls.SKIP) + public _FinalStage auth(Optional auth) { + this.auth = auth; + return this; + } + + /** + *

Query parameters appended to the webhook URL.

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

Query parameters appended to the webhook URL.

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

Custom HTTP headers forwarded with each delivery.

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

Custom HTTP headers forwarded with each delivery.

+ */ + @java.lang.Override + @JsonSetter(value = "headers", nulls = Nulls.SKIP) + public _FinalStage headers(Optional> headers) { + this.headers = headers; + return this; + } + + @java.lang.Override + public _FinalStage method(HttpMethod method) { + this.method = Optional.ofNullable(method); + return this; + } + + @java.lang.Override + @JsonSetter(value = "method", nulls = Nulls.SKIP) + public _FinalStage method(Optional method) { + this.method = method; + return this; + } + + @java.lang.Override + public _FinalStage deliveryMode(DeliveryMode deliveryMode) { + this.deliveryMode = Optional.ofNullable(deliveryMode); + return this; + } + + @java.lang.Override + @JsonSetter(value = "delivery_mode", nulls = Nulls.SKIP) + public _FinalStage deliveryMode(Optional deliveryMode) { + this.deliveryMode = deliveryMode; + return this; + } + + @java.lang.Override + public _FinalStage type(WebhookType type) { + this.type = Optional.ofNullable(type); + return this; + } + + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public CreateWebhookRequestDto build() { + return new CreateWebhookRequestDto( + name, + url, + type, + deliveryMode, + method, + headers, + params, + auth, + formatterConfig, + 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/resources/webhooks/requests/DeleteWebhookRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/DeleteWebhookRequest.java new file mode 100644 index 0000000..c091afe --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/DeleteWebhookRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteWebhookRequest.Builder.class) +public final class DeleteWebhookRequest { + private final Map additionalProperties; + + private DeleteWebhookRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteWebhookRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteWebhookRequest other) { + return this; + } + + public DeleteWebhookRequest build() { + return new DeleteWebhookRequest(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/webhooks/requests/GetWebhookDeliveryHistoryRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookDeliveryHistoryRequest.java new file mode 100644 index 0000000..de36611 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookDeliveryHistoryRequest.java @@ -0,0 +1,255 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 com.newscatcher.catchall.types.MappableResourceType; +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 = GetWebhookDeliveryHistoryRequest.Builder.class) +public final class GetWebhookDeliveryHistoryRequest { + private final MappableResourceType resourceType; + + private final String resourceId; + + private final Optional page; + + private final Optional pageSize; + + private final Map additionalProperties; + + private GetWebhookDeliveryHistoryRequest( + MappableResourceType resourceType, + String resourceId, + Optional page, + Optional pageSize, + Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of the resource to retrieve delivery history for. + */ + @JsonProperty("resource_type") + public MappableResourceType getResourceType() { + return resourceType; + } + + /** + * @return Identifier of the resource to retrieve delivery history for. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of records 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 GetWebhookDeliveryHistoryRequest && equalTo((GetWebhookDeliveryHistoryRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetWebhookDeliveryHistoryRequest other) { + return resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && page.equals(other.page) + && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.resourceId, this.page, this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + /** + *

Type of the resource to retrieve delivery history for.

+ */ + ResourceIdStage resourceType(@NotNull MappableResourceType resourceType); + + Builder from(GetWebhookDeliveryHistoryRequest other); + } + + public interface ResourceIdStage { + /** + *

Identifier of the resource to retrieve delivery history for.

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

Page number to retrieve.

+ */ + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + /** + *

Number of records per page.

+ */ + _FinalStage pageSize(Optional pageSize); + + _FinalStage pageSize(Integer pageSize); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ResourceTypeStage, ResourceIdStage, _FinalStage { + private MappableResourceType resourceType; + + private String resourceId; + + private Optional pageSize = Optional.empty(); + + private Optional page = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetWebhookDeliveryHistoryRequest other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + /** + *

Type of the resource to retrieve delivery history for.

+ *

Type of the resource to retrieve delivery history for.

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

Identifier of the resource to retrieve delivery history for.

+ *

Identifier of the resource to retrieve delivery history for.

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

Number of records per page.

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

Number of records per page.

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

Page number to retrieve.

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

Page number to retrieve.

+ */ + @java.lang.Override + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public _FinalStage page(Optional page) { + this.page = page; + return this; + } + + @java.lang.Override + public GetWebhookDeliveryHistoryRequest build() { + return new GetWebhookDeliveryHistoryRequest(resourceType, resourceId, 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/resources/webhooks/requests/GetWebhookRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookRequest.java new file mode 100644 index 0000000..14ec186 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/GetWebhookRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetWebhookRequest.Builder.class) +public final class GetWebhookRequest { + private final Map additionalProperties; + + private GetWebhookRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetWebhookRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetWebhookRequest other) { + return this; + } + + public GetWebhookRequest build() { + return new GetWebhookRequest(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/webhooks/requests/ListWebhookResourcesRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhookResourcesRequest.java new file mode 100644 index 0000000..2a267e9 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhookResourcesRequest.java @@ -0,0 +1,166 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 com.newscatcher.catchall.types.MappableResourceType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListWebhookResourcesRequest.Builder.class) +public final class ListWebhookResourcesRequest { + private final Optional resourceType; + + private final Optional page; + + private final Optional pageSize; + + private final Map additionalProperties; + + private ListWebhookResourcesRequest( + Optional resourceType, + Optional page, + Optional pageSize, + Map additionalProperties) { + this.resourceType = resourceType; + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resource_type") + public Optional getResourceType() { + return resourceType; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of assignments 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 ListWebhookResourcesRequest && equalTo((ListWebhookResourcesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListWebhookResourcesRequest other) { + return resourceType.equals(other.resourceType) && page.equals(other.page) && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, 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 resourceType = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListWebhookResourcesRequest other) { + resourceType(other.getResourceType()); + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "resource_type", nulls = Nulls.SKIP) + public Builder resourceType(Optional resourceType) { + this.resourceType = resourceType; + return this; + } + + public Builder resourceType(MappableResourceType resourceType) { + this.resourceType = Optional.ofNullable(resourceType); + 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 assignments 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 ListWebhookResourcesRequest build() { + return new ListWebhookResourcesRequest(resourceType, 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/webhooks/requests/ListWebhooksForResourceRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksForResourceRequest.java new file mode 100644 index 0000000..c27c392 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksForResourceRequest.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 = ListWebhooksForResourceRequest.Builder.class) +public final class ListWebhooksForResourceRequest { + private final Optional isActive; + + private final Optional page; + + private final Optional pageSize; + + private final Map additionalProperties; + + private ListWebhooksForResourceRequest( + Optional isActive, + Optional page, + Optional pageSize, + Map additionalProperties) { + this.isActive = isActive; + this.page = page; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Filter by active status. Omit to return webhooks regardless of status. + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of webhooks 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 ListWebhooksForResourceRequest && equalTo((ListWebhooksForResourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListWebhooksForResourceRequest other) { + return isActive.equals(other.isActive) && page.equals(other.page) && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.isActive, 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 isActive = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListWebhooksForResourceRequest other) { + isActive(other.getIsActive()); + page(other.getPage()); + pageSize(other.getPageSize()); + return this; + } + + /** + *

Filter by active status. Omit to return webhooks regardless of status.

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + 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 webhooks 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 ListWebhooksForResourceRequest build() { + return new ListWebhooksForResourceRequest(isActive, 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/webhooks/requests/ListWebhooksRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java new file mode 100644 index 0000000..d5efc70 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/ListWebhooksRequest.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 = ListWebhooksRequest.Builder.class) +public final class ListWebhooksRequest { + private final Optional page; + + private final Optional pageSize; + + private final Optional search; + + private final Map additionalProperties; + + private ListWebhooksRequest( + Optional page, + Optional pageSize, + Optional search, + Map additionalProperties) { + this.page = page; + this.pageSize = pageSize; + this.search = search; + this.additionalProperties = additionalProperties; + } + + /** + * @return Page number to retrieve. + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return Number of webhooks per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + /** + * @return Filter results by text (case-insensitive substring match). + */ + @JsonProperty("search") + public Optional getSearch() { + return search; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListWebhooksRequest && equalTo((ListWebhooksRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListWebhooksRequest other) { + return page.equals(other.page) && pageSize.equals(other.pageSize) && search.equals(other.search); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.pageSize, this.search); + } + + @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(); + + private Optional search = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListWebhooksRequest other) { + page(other.getPage()); + pageSize(other.getPageSize()); + search(other.getSearch()); + 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 webhooks 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; + } + + /** + *

Filter results by text (case-insensitive substring match).

+ */ + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public Builder search(Optional search) { + this.search = search; + return this; + } + + public Builder search(String search) { + this.search = Optional.ofNullable(search); + return this; + } + + public ListWebhooksRequest build() { + return new ListWebhooksRequest(page, pageSize, search, 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/webhooks/requests/RemoveWebhookResourceRequest.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/RemoveWebhookResourceRequest.java new file mode 100644 index 0000000..2a6ef83 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/RemoveWebhookResourceRequest.java @@ -0,0 +1,69 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RemoveWebhookResourceRequest.Builder.class) +public final class RemoveWebhookResourceRequest { + private final Map additionalProperties; + + private RemoveWebhookResourceRequest(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RemoveWebhookResourceRequest; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @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 { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RemoveWebhookResourceRequest other) { + return this; + } + + public RemoveWebhookResourceRequest build() { + return new RemoveWebhookResourceRequest(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/webhooks/requests/TestWebhookRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/TestWebhookRequestDto.java new file mode 100644 index 0000000..7787030 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/TestWebhookRequestDto.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 = TestWebhookRequestDto.Builder.class) +public final class TestWebhookRequestDto { + private final Optional> payload; + + private final Map additionalProperties; + + private TestWebhookRequestDto(Optional> payload, Map additionalProperties) { + this.payload = payload; + this.additionalProperties = additionalProperties; + } + + /** + * @return Custom payload to send in the test request. If omitted, a synthetic + * test payload is sent. + */ + @JsonProperty("payload") + public Optional> getPayload() { + return payload; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TestWebhookRequestDto && equalTo((TestWebhookRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TestWebhookRequestDto other) { + return payload.equals(other.payload); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.payload); + } + + @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> payload = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TestWebhookRequestDto other) { + payload(other.getPayload()); + return this; + } + + /** + *

Custom payload to send in the test request. If omitted, a synthetic + * test payload is sent.

+ */ + @JsonSetter(value = "payload", nulls = Nulls.SKIP) + public Builder payload(Optional> payload) { + this.payload = payload; + return this; + } + + public Builder payload(Map payload) { + this.payload = Optional.ofNullable(payload); + return this; + } + + public TestWebhookRequestDto build() { + return new TestWebhookRequestDto(payload, 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/webhooks/requests/UpdateWebhookRequestDto.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/UpdateWebhookRequestDto.java new file mode 100644 index 0000000..2e841d5 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/requests/UpdateWebhookRequestDto.java @@ -0,0 +1,413 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.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 com.newscatcher.catchall.resources.webhooks.types.UpdateWebhookRequestDtoAuth; +import com.newscatcher.catchall.types.DeliveryMode; +import com.newscatcher.catchall.types.HttpMethod; +import com.newscatcher.catchall.types.WebhookType; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateWebhookRequestDto.Builder.class) +public final class UpdateWebhookRequestDto { + private final Optional name; + + private final Optional url; + + private final Optional type; + + private final Optional deliveryMode; + + private final Optional method; + + private final Optional> headers; + + private final Optional> params; + + private final Optional auth; + + private final Optional> formatterConfig; + + private final Optional isActive; + + private final Map additionalProperties; + + private UpdateWebhookRequestDto( + Optional name, + Optional url, + Optional type, + Optional deliveryMode, + Optional method, + Optional> headers, + Optional> params, + Optional auth, + Optional> formatterConfig, + Optional isActive, + Map additionalProperties) { + this.name = name; + this.url = url; + this.type = type; + this.deliveryMode = deliveryMode; + this.method = method; + this.headers = headers; + this.params = params; + this.auth = auth; + this.formatterConfig = formatterConfig; + this.isActive = isActive; + this.additionalProperties = additionalProperties; + } + + /** + * @return Updated webhook name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Updated destination URL. Must use HTTPS. Type-specific URL rules apply. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("delivery_mode") + public Optional getDeliveryMode() { + return deliveryMode; + } + + @JsonProperty("method") + public Optional getMethod() { + return method; + } + + /** + * @return Updated HTTP headers. Replaces existing headers entirely. + */ + @JsonProperty("headers") + public Optional> getHeaders() { + return headers; + } + + /** + * @return Updated query parameters. Replaces existing params entirely. + */ + @JsonProperty("params") + public Optional> getParams() { + return params; + } + + /** + * @return Updated authentication configuration. Replaces existing auth entirely. + */ + @JsonProperty("auth") + public Optional getAuth() { + return auth; + } + + /** + * @return Updated formatter configuration. + */ + @JsonIgnore + public Optional> getFormatterConfig() { + if (formatterConfig == null) { + return Optional.empty(); + } + return formatterConfig; + } + + /** + * @return Set to false to disable delivery without deleting the webhook. + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("formatter_config") + private Optional> _getFormatterConfig() { + return formatterConfig; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateWebhookRequestDto && equalTo((UpdateWebhookRequestDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateWebhookRequestDto other) { + return name.equals(other.name) + && url.equals(other.url) + && type.equals(other.type) + && deliveryMode.equals(other.deliveryMode) + && method.equals(other.method) + && headers.equals(other.headers) + && params.equals(other.params) + && auth.equals(other.auth) + && formatterConfig.equals(other.formatterConfig) + && isActive.equals(other.isActive); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, + this.url, + this.type, + this.deliveryMode, + this.method, + this.headers, + this.params, + this.auth, + this.formatterConfig, + this.isActive); + } + + @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 name = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional deliveryMode = Optional.empty(); + + private Optional method = Optional.empty(); + + private Optional> headers = Optional.empty(); + + private Optional> params = Optional.empty(); + + private Optional auth = Optional.empty(); + + private Optional> formatterConfig = Optional.empty(); + + private Optional isActive = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateWebhookRequestDto other) { + name(other.getName()); + url(other.getUrl()); + type(other.getType()); + deliveryMode(other.getDeliveryMode()); + method(other.getMethod()); + headers(other.getHeaders()); + params(other.getParams()); + auth(other.getAuth()); + formatterConfig(other.getFormatterConfig()); + isActive(other.getIsActive()); + return this; + } + + /** + *

Updated webhook name.

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

Updated destination URL. Must use HTTPS. Type-specific URL rules apply.

+ */ + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(WebhookType type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "delivery_mode", nulls = Nulls.SKIP) + public Builder deliveryMode(Optional deliveryMode) { + this.deliveryMode = deliveryMode; + return this; + } + + public Builder deliveryMode(DeliveryMode deliveryMode) { + this.deliveryMode = Optional.ofNullable(deliveryMode); + return this; + } + + @JsonSetter(value = "method", nulls = Nulls.SKIP) + public Builder method(Optional method) { + this.method = method; + return this; + } + + public Builder method(HttpMethod method) { + this.method = Optional.ofNullable(method); + return this; + } + + /** + *

Updated HTTP headers. Replaces existing headers entirely.

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

Updated query parameters. Replaces existing params entirely.

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

Updated authentication configuration. Replaces existing auth entirely.

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

Updated formatter configuration.

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

Set to false to disable delivery without deleting the webhook.

+ */ + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public Builder isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + public Builder isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + public UpdateWebhookRequestDto build() { + return new UpdateWebhookRequestDto( + name, + url, + type, + deliveryMode, + method, + headers, + params, + auth, + formatterConfig, + isActive, + 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/webhooks/types/CreateWebhookRequestDtoAuth.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/types/CreateWebhookRequestDtoAuth.java new file mode 100644 index 0000000..c964802 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/types/CreateWebhookRequestDtoAuth.java @@ -0,0 +1,286 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import com.newscatcher.catchall.types.ApiKeyAuthDto; +import com.newscatcher.catchall.types.BasicAuthDto; +import com.newscatcher.catchall.types.BearerAuthDto; +import java.util.Objects; +import java.util.Optional; + +public final class CreateWebhookRequestDtoAuth { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private CreateWebhookRequestDtoAuth(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static CreateWebhookRequestDtoAuth bearer(BearerAuthDto value) { + return new CreateWebhookRequestDtoAuth(new BearerValue(value)); + } + + public static CreateWebhookRequestDtoAuth apiKey(ApiKeyAuthDto value) { + return new CreateWebhookRequestDtoAuth(new ApiKeyValue(value)); + } + + public static CreateWebhookRequestDtoAuth basic(BasicAuthDto value) { + return new CreateWebhookRequestDtoAuth(new BasicValue(value)); + } + + public boolean isBearer() { + return value instanceof BearerValue; + } + + public boolean isApiKey() { + return value instanceof ApiKeyValue; + } + + public boolean isBasic() { + return value instanceof BasicValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getBearer() { + if (isBearer()) { + return Optional.of(((BearerValue) value).value); + } + return Optional.empty(); + } + + public Optional getApiKey() { + if (isApiKey()) { + return Optional.of(((ApiKeyValue) value).value); + } + return Optional.empty(); + } + + public Optional getBasic() { + if (isBasic()) { + return Optional.of(((BasicValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateWebhookRequestDtoAuth + && value.equals(((CreateWebhookRequestDtoAuth) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitBearer(BearerAuthDto bearer); + + T visitApiKey(ApiKeyAuthDto apiKey); + + T visitBasic(BasicAuthDto basic); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(BearerValue.class), + @JsonSubTypes.Type(ApiKeyValue.class), + @JsonSubTypes.Type(BasicValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("bearer") + @JsonIgnoreProperties("type") + private static final class BearerValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private BearerAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private BearerValue() {} + + private BearerValue(BearerAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitBearer(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BearerValue && equalTo((BearerValue) other); + } + + private boolean equalTo(BearerValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "CreateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonTypeName("api_key") + @JsonIgnoreProperties("type") + private static final class ApiKeyValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private ApiKeyAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ApiKeyValue() {} + + private ApiKeyValue(ApiKeyAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitApiKey(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyValue && equalTo((ApiKeyValue) other); + } + + private boolean equalTo(ApiKeyValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "CreateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonTypeName("basic") + @JsonIgnoreProperties("type") + private static final class BasicValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private BasicAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private BasicValue() {} + + private BasicValue(BasicAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitBasic(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BasicValue && equalTo((BasicValue) other); + } + + private boolean equalTo(BasicValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "CreateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "CreateWebhookRequestDtoAuth{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/resources/webhooks/types/UpdateWebhookRequestDtoAuth.java b/src/main/java/com/newscatcher/catchall/resources/webhooks/types/UpdateWebhookRequestDtoAuth.java new file mode 100644 index 0000000..2f8293f --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/resources/webhooks/types/UpdateWebhookRequestDtoAuth.java @@ -0,0 +1,286 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.resources.webhooks.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import com.newscatcher.catchall.types.ApiKeyAuthDto; +import com.newscatcher.catchall.types.BasicAuthDto; +import com.newscatcher.catchall.types.BearerAuthDto; +import java.util.Objects; +import java.util.Optional; + +public final class UpdateWebhookRequestDtoAuth { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private UpdateWebhookRequestDtoAuth(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static UpdateWebhookRequestDtoAuth bearer(BearerAuthDto value) { + return new UpdateWebhookRequestDtoAuth(new BearerValue(value)); + } + + public static UpdateWebhookRequestDtoAuth apiKey(ApiKeyAuthDto value) { + return new UpdateWebhookRequestDtoAuth(new ApiKeyValue(value)); + } + + public static UpdateWebhookRequestDtoAuth basic(BasicAuthDto value) { + return new UpdateWebhookRequestDtoAuth(new BasicValue(value)); + } + + public boolean isBearer() { + return value instanceof BearerValue; + } + + public boolean isApiKey() { + return value instanceof ApiKeyValue; + } + + public boolean isBasic() { + return value instanceof BasicValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getBearer() { + if (isBearer()) { + return Optional.of(((BearerValue) value).value); + } + return Optional.empty(); + } + + public Optional getApiKey() { + if (isApiKey()) { + return Optional.of(((ApiKeyValue) value).value); + } + return Optional.empty(); + } + + public Optional getBasic() { + if (isBasic()) { + return Optional.of(((BasicValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateWebhookRequestDtoAuth + && value.equals(((UpdateWebhookRequestDtoAuth) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitBearer(BearerAuthDto bearer); + + T visitApiKey(ApiKeyAuthDto apiKey); + + T visitBasic(BasicAuthDto basic); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(BearerValue.class), + @JsonSubTypes.Type(ApiKeyValue.class), + @JsonSubTypes.Type(BasicValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("bearer") + @JsonIgnoreProperties("type") + private static final class BearerValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private BearerAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private BearerValue() {} + + private BearerValue(BearerAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitBearer(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BearerValue && equalTo((BearerValue) other); + } + + private boolean equalTo(BearerValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "UpdateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonTypeName("api_key") + @JsonIgnoreProperties("type") + private static final class ApiKeyValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private ApiKeyAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ApiKeyValue() {} + + private ApiKeyValue(ApiKeyAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitApiKey(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyValue && equalTo((ApiKeyValue) other); + } + + private boolean equalTo(ApiKeyValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "UpdateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonTypeName("basic") + @JsonIgnoreProperties("type") + private static final class BasicValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private BasicAuthDto value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private BasicValue() {} + + private BasicValue(BasicAuthDto value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitBasic(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BasicValue && equalTo((BasicValue) other); + } + + private boolean equalTo(BasicValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "UpdateWebhookRequestDtoAuth{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "UpdateWebhookRequestDtoAuth{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/AddResourceResponseDto.java b/src/main/java/com/newscatcher/catchall/types/AddResourceResponseDto.java new file mode 100644 index 0000000..4aaf627 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/AddResourceResponseDto.java @@ -0,0 +1,227 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AddResourceResponseDto.Builder.class) +public final class AddResourceResponseDto { + private final boolean success; + + private final String message; + + private final List results; + + private final Map additionalProperties; + + private AddResourceResponseDto( + boolean success, + String message, + List results, + Map additionalProperties) { + this.success = success; + this.message = message; + this.results = results; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the overall operation succeeded. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Top-level result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Per-resource outcome, one entry per submitted resource. + */ + @JsonProperty("results") + public List getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AddResourceResponseDto && equalTo((AddResourceResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AddResourceResponseDto other) { + return success == other.success && message.equals(other.message) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the overall operation succeeded.

+ */ + MessageStage success(boolean success); + + Builder from(AddResourceResponseDto other); + } + + public interface MessageStage { + /** + *

Top-level result message.

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

Per-resource outcome, one entry per submitted resource.

+ */ + _FinalStage results(List results); + + _FinalStage addResults(ResourceResultDto results); + + _FinalStage addAllResults(List results); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + private List results = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AddResourceResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + results(other.getResults()); + return this; + } + + /** + *

True if the overall operation succeeded.

+ *

True if the overall operation succeeded.

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

Top-level result message.

+ *

Top-level result message.

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

Per-resource outcome, one entry per submitted resource.

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

Per-resource outcome, one entry per submitted resource.

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

Per-resource outcome, one entry per submitted resource.

+ */ + @java.lang.Override + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public _FinalStage results(List results) { + this.results.clear(); + if (results != null) { + this.results.addAll(results); + } + return this; + } + + @java.lang.Override + public AddResourceResponseDto build() { + return new AddResourceResponseDto(success, message, results, 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/ApiKeyAuthDto.java b/src/main/java/com/newscatcher/catchall/types/ApiKeyAuthDto.java new file mode 100644 index 0000000..0a9d663 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ApiKeyAuthDto.java @@ -0,0 +1,162 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ApiKeyAuthDto.Builder.class) +public final class ApiKeyAuthDto { + private final String header; + + private final String value; + + private final Map additionalProperties; + + private ApiKeyAuthDto(String header, String value, Map additionalProperties) { + this.header = header; + this.value = value; + this.additionalProperties = additionalProperties; + } + + /** + * @return HTTP header name for the API key. + */ + @JsonProperty("header") + public String getHeader() { + return header; + } + + /** + * @return API key value. + */ + @JsonProperty("value") + public String getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ApiKeyAuthDto && equalTo((ApiKeyAuthDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ApiKeyAuthDto other) { + return header.equals(other.header) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.header, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static HeaderStage builder() { + return new Builder(); + } + + public interface HeaderStage { + /** + *

HTTP header name for the API key.

+ */ + ValueStage header(@NotNull String header); + + Builder from(ApiKeyAuthDto other); + } + + public interface ValueStage { + /** + *

API key value.

+ */ + _FinalStage value(@NotNull String value); + } + + public interface _FinalStage { + ApiKeyAuthDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements HeaderStage, ValueStage, _FinalStage { + private String header; + + private String value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ApiKeyAuthDto other) { + header(other.getHeader()); + value(other.getValue()); + return this; + } + + /** + *

HTTP header name for the API key.

+ *

HTTP header name for the API key.

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

API key value.

+ *

API key value.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull String value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + public ApiKeyAuthDto build() { + return new ApiKeyAuthDto(header, value, 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/AssignWebhookResourceResponseDto.java b/src/main/java/com/newscatcher/catchall/types/AssignWebhookResourceResponseDto.java new file mode 100644 index 0000000..136282f --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/AssignWebhookResourceResponseDto.java @@ -0,0 +1,262 @@ +/** + * 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.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AssignWebhookResourceResponseDto.Builder.class) +public final class AssignWebhookResourceResponseDto { + private final boolean success; + + private final Optional message; + + private final Optional alreadyExisted; + + private final Optional mapping; + + private final Map additionalProperties; + + private AssignWebhookResourceResponseDto( + boolean success, + Optional message, + Optional alreadyExisted, + Optional mapping, + Map additionalProperties) { + this.success = success; + this.message = message; + this.alreadyExisted = alreadyExisted; + this.mapping = mapping; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + /** + * @return True if the assignment already existed before this request. + */ + @JsonProperty("already_existed") + public Optional getAlreadyExisted() { + return alreadyExisted; + } + + /** + * @return The created or existing resource mapping. + */ + @JsonProperty("mapping") + public Optional getMapping() { + return mapping; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AssignWebhookResourceResponseDto && equalTo((AssignWebhookResourceResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AssignWebhookResourceResponseDto other) { + return success == other.success + && message.equals(other.message) + && alreadyExisted.equals(other.alreadyExisted) + && mapping.equals(other.mapping); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.alreadyExisted, this.mapping); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + _FinalStage success(boolean success); + + Builder from(AssignWebhookResourceResponseDto other); + } + + public interface _FinalStage { + AssignWebhookResourceResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Human-readable result message.

+ */ + _FinalStage message(Optional message); + + _FinalStage message(String message); + + /** + *

True if the assignment already existed before this request.

+ */ + _FinalStage alreadyExisted(Optional alreadyExisted); + + _FinalStage alreadyExisted(Boolean alreadyExisted); + + /** + *

The created or existing resource mapping.

+ */ + _FinalStage mapping(Optional mapping); + + _FinalStage mapping(WebhookResourceMappingResponseDto mapping); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, _FinalStage { + private boolean success; + + private Optional mapping = Optional.empty(); + + private Optional alreadyExisted = Optional.empty(); + + private Optional message = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AssignWebhookResourceResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + alreadyExisted(other.getAlreadyExisted()); + mapping(other.getMapping()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

The created or existing resource mapping.

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

The created or existing resource mapping.

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

True if the assignment already existed before this request.

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

True if the assignment already existed before this request.

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

Human-readable result message.

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

Human-readable result message.

+ */ + @java.lang.Override + @JsonSetter(value = "message", nulls = Nulls.SKIP) + public _FinalStage message(Optional message) { + this.message = message; + return this; + } + + @java.lang.Override + public AssignWebhookResourceResponseDto build() { + return new AssignWebhookResourceResponseDto( + success, message, alreadyExisted, mapping, 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/BasicAuthDto.java b/src/main/java/com/newscatcher/catchall/types/BasicAuthDto.java new file mode 100644 index 0000000..4b81204 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/BasicAuthDto.java @@ -0,0 +1,162 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BasicAuthDto.Builder.class) +public final class BasicAuthDto { + private final String username; + + private final String password; + + private final Map additionalProperties; + + private BasicAuthDto(String username, String password, Map additionalProperties) { + this.username = username; + this.password = password; + this.additionalProperties = additionalProperties; + } + + /** + * @return Basic auth username. + */ + @JsonProperty("username") + public String getUsername() { + return username; + } + + /** + * @return Basic auth password. + */ + @JsonProperty("password") + public String getPassword() { + return password; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BasicAuthDto && equalTo((BasicAuthDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BasicAuthDto other) { + return username.equals(other.username) && password.equals(other.password); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.username, this.password); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UsernameStage builder() { + return new Builder(); + } + + public interface UsernameStage { + /** + *

Basic auth username.

+ */ + PasswordStage username(@NotNull String username); + + Builder from(BasicAuthDto other); + } + + public interface PasswordStage { + /** + *

Basic auth password.

+ */ + _FinalStage password(@NotNull String password); + } + + public interface _FinalStage { + BasicAuthDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UsernameStage, PasswordStage, _FinalStage { + private String username; + + private String password; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BasicAuthDto other) { + username(other.getUsername()); + password(other.getPassword()); + return this; + } + + /** + *

Basic auth username.

+ *

Basic auth username.

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

Basic auth password.

+ *

Basic auth password.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("password") + public _FinalStage password(@NotNull String password) { + this.password = Objects.requireNonNull(password, "password must not be null"); + return this; + } + + @java.lang.Override + public BasicAuthDto build() { + return new BasicAuthDto(username, password, 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/BearerAuthDto.java b/src/main/java/com/newscatcher/catchall/types/BearerAuthDto.java new file mode 100644 index 0000000..85547e0 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/BearerAuthDto.java @@ -0,0 +1,129 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BearerAuthDto.Builder.class) +public final class BearerAuthDto { + private final String token; + + private final Map additionalProperties; + + private BearerAuthDto(String token, Map additionalProperties) { + this.token = token; + this.additionalProperties = additionalProperties; + } + + /** + * @return Bearer token sent in the Authorization header. + */ + @JsonProperty("token") + public String getToken() { + return token; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BearerAuthDto && equalTo((BearerAuthDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BearerAuthDto other) { + return token.equals(other.token); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.token); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TokenStage builder() { + return new Builder(); + } + + public interface TokenStage { + /** + *

Bearer token sent in the Authorization header.

+ */ + _FinalStage token(@NotNull String token); + + Builder from(BearerAuthDto other); + } + + public interface _FinalStage { + BearerAuthDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TokenStage, _FinalStage { + private String token; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BearerAuthDto other) { + token(other.getToken()); + return this; + } + + /** + *

Bearer token sent in the Authorization header.

+ *

Bearer token sent in the Authorization header.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("token") + public _FinalStage token(@NotNull String token) { + this.token = Objects.requireNonNull(token, "token must not be null"); + return this; + } + + @java.lang.Override + public BearerAuthDto build() { + return new BearerAuthDto(token, 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/ConnectedEntity.java b/src/main/java/com/newscatcher/catchall/types/ConnectedEntity.java index 58d9ab2..57f8063 100644 --- a/src/main/java/com/newscatcher/catchall/types/ConnectedEntity.java +++ b/src/main/java/com/newscatcher/catchall/types/ConnectedEntity.java @@ -100,7 +100,7 @@ public String getType() { /** * @return The stored attributes for this entity. Present only when attributes exist in the database. - *

The field name matches the value of type — for example, "company" type entities have a company field.

+ *

The field name matches the value of type — for example, "company" type entities have a company field.

*/ @JsonProperty("company") public Optional getCompany() { @@ -193,7 +193,7 @@ public interface _FinalStage { /** *

The stored attributes for this entity. Present only when attributes exist in the database.

- *

The field name matches the value of type — for example, "company" type entities have a company field.

+ *

The field name matches the value of type — for example, "company" type entities have a company field.

*/ _FinalStage company(Optional company); @@ -305,7 +305,7 @@ public _FinalStage type(@NotNull String type) { /** *

The stored attributes for this entity. Present only when attributes exist in the database.

- *

The field name matches the value of type — for example, "company" type entities have a company field.

+ *

The field name matches the value of type — for example, "company" type entities have a company field.

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

The stored attributes for this entity. Present only when attributes exist in the database.

- *

The field name matches the value of type — for example, "company" type entities have a company field.

+ *

The field name matches the value of type — for example, "company" type entities have a company field.

*/ @java.lang.Override @JsonSetter(value = "company", nulls = Nulls.SKIP) diff --git a/src/main/java/com/newscatcher/catchall/types/CreateProjectResponseDto.java b/src/main/java/com/newscatcher/catchall/types/CreateProjectResponseDto.java new file mode 100644 index 0000000..8ac0230 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/CreateProjectResponseDto.java @@ -0,0 +1,232 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateProjectResponseDto.Builder.class) +public final class CreateProjectResponseDto { + private final boolean success; + + private final String message; + + private final String projectId; + + private final String name; + + private final Map additionalProperties; + + private CreateProjectResponseDto( + boolean success, String message, String projectId, String name, Map additionalProperties) { + this.success = success; + this.message = message; + this.projectId = projectId; + this.name = name; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Project identifier. + */ + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + + /** + * @return Name of the created project. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateProjectResponseDto && equalTo((CreateProjectResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateProjectResponseDto other) { + return success == other.success + && message.equals(other.message) + && projectId.equals(other.projectId) + && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.projectId, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(CreateProjectResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

+ */ + ProjectIdStage message(@NotNull String message); + } + + public interface ProjectIdStage { + /** + *

Project identifier.

+ */ + NameStage projectId(@NotNull String projectId); + } + + public interface NameStage { + /** + *

Name of the created project.

+ */ + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + CreateProjectResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, ProjectIdStage, NameStage, _FinalStage { + private boolean success; + + private String message; + + private String projectId; + + private String name; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateProjectResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + projectId(other.getProjectId()); + name(other.getName()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

Project identifier.

+ *

Project identifier.

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

Name of the created project.

+ *

Name of the created project.

+ * @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; + } + + @java.lang.Override + public CreateProjectResponseDto build() { + return new CreateProjectResponseDto(success, message, projectId, name, 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/CreateWebhookResponseDto.java b/src/main/java/com/newscatcher/catchall/types/CreateWebhookResponseDto.java new file mode 100644 index 0000000..09e3d8c --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/CreateWebhookResponseDto.java @@ -0,0 +1,209 @@ +/** + * 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.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 = CreateWebhookResponseDto.Builder.class) +public final class CreateWebhookResponseDto { + private final boolean success; + + private final String message; + + private final Optional webhook; + + private final Map additionalProperties; + + private CreateWebhookResponseDto( + boolean success, + String message, + Optional webhook, + Map additionalProperties) { + this.success = success; + this.message = message; + this.webhook = webhook; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the webhook was created; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return The created webhook object. + */ + @JsonProperty("webhook") + public Optional getWebhook() { + return webhook; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateWebhookResponseDto && equalTo((CreateWebhookResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateWebhookResponseDto other) { + return success == other.success && message.equals(other.message) && webhook.equals(other.webhook); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.webhook); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the webhook was created; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(CreateWebhookResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

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

The created webhook object.

+ */ + _FinalStage webhook(Optional webhook); + + _FinalStage webhook(WebhookResponseDto webhook); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + private Optional webhook = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateWebhookResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + webhook(other.getWebhook()); + return this; + } + + /** + *

True if the webhook was created; false otherwise.

+ *

True if the webhook was created; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

The created webhook object.

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

The created webhook object.

+ */ + @java.lang.Override + @JsonSetter(value = "webhook", nulls = Nulls.SKIP) + public _FinalStage webhook(Optional webhook) { + this.webhook = webhook; + return this; + } + + @java.lang.Override + public CreateWebhookResponseDto build() { + return new CreateWebhookResponseDto(success, message, webhook, 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/DeleteJobResponseDto.java b/src/main/java/com/newscatcher/catchall/types/DeleteJobResponseDto.java index 3c17b46..5ac8a2f 100644 --- a/src/main/java/com/newscatcher/catchall/types/DeleteJobResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/DeleteJobResponseDto.java @@ -43,7 +43,7 @@ private DeleteJobResponseDto( } /** - * @return Whether the delete operation succeeded. + * @return True if the delete operation succeeded; false otherwise. */ @JsonProperty("success") public boolean getSuccess() { @@ -115,7 +115,7 @@ public static SuccessStage builder() { public interface SuccessStage { /** - *

Whether the delete operation succeeded.

+ *

True if the delete operation succeeded; false otherwise.

*/ _FinalStage success(boolean success); @@ -170,8 +170,8 @@ public Builder from(DeleteJobResponseDto other) { } /** - *

Whether the delete operation succeeded.

- *

Whether the delete operation succeeded.

+ *

True if the delete operation succeeded; false otherwise.

+ *

True if the delete operation succeeded; false otherwise.

* @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/DeleteMonitorResponseDto.java b/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java index e4e755c..e69f787 100644 --- a/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/DeleteMonitorResponseDto.java @@ -43,7 +43,7 @@ private DeleteMonitorResponseDto( } /** - * @return Whether the delete operation succeeded. + * @return True if the delete operation succeeded; false otherwise. */ @JsonProperty("success") public boolean getSuccess() { @@ -115,7 +115,7 @@ public static SuccessStage builder() { public interface SuccessStage { /** - *

Whether the delete operation succeeded.

+ *

True if the delete operation succeeded; false otherwise.

*/ _FinalStage success(boolean success); @@ -170,8 +170,8 @@ public Builder from(DeleteMonitorResponseDto other) { } /** - *

Whether the delete operation succeeded.

- *

Whether the delete operation succeeded.

+ *

True if the delete operation succeeded; false otherwise.

+ *

True if the delete operation succeeded; false otherwise.

* @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/DeliveryHistoryItemDto.java b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java new file mode 100644 index 0000000..73b1646 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryItemDto.java @@ -0,0 +1,597 @@ +/** + * 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.time.OffsetDateTime; +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 = DeliveryHistoryItemDto.Builder.class) +public final class DeliveryHistoryItemDto { + private final int id; + + private final String webhookId; + + private final MappableResourceType resourceType; + + private final String resourceId; + + private final Optional> additionalInfo; + + private final int statusCode; + + private final int attemptNumber; + + private final OffsetDateTime timestamp; + + private final DeliveryStatus deliveryStatus; + + private final Optional errorMessage; + + private final Optional warningMessage; + + private final Map additionalProperties; + + private DeliveryHistoryItemDto( + int id, + String webhookId, + MappableResourceType resourceType, + String resourceId, + Optional> additionalInfo, + int statusCode, + int attemptNumber, + OffsetDateTime timestamp, + DeliveryStatus deliveryStatus, + Optional errorMessage, + Optional warningMessage, + Map additionalProperties) { + this.id = id; + this.webhookId = webhookId; + this.resourceType = resourceType; + this.resourceId = resourceId; + this.additionalInfo = additionalInfo; + this.statusCode = statusCode; + this.attemptNumber = attemptNumber; + this.timestamp = timestamp; + this.deliveryStatus = deliveryStatus; + this.errorMessage = errorMessage; + this.warningMessage = warningMessage; + this.additionalProperties = additionalProperties; + } + + /** + * @return Delivery record identifier. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return Identifier of the webhook that was dispatched. + */ + @JsonProperty("webhook_id") + public String getWebhookId() { + return webhookId; + } + + /** + * @return Type of the resource that triggered the delivery. + */ + @JsonProperty("resource_type") + public MappableResourceType getResourceType() { + return resourceType; + } + + /** + * @return Identifier of the resource that triggered the delivery. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return Extra context about the triggering event, such as job query or monitor schedule. + */ + @JsonProperty("additional_info") + public Optional> getAdditionalInfo() { + return additionalInfo; + } + + /** + * @return HTTP response code returned by the webhook endpoint. + */ + @JsonProperty("status_code") + public int getStatusCode() { + return statusCode; + } + + /** + * @return Delivery attempt number. 1 indicates the first attempt. + */ + @JsonProperty("attempt_number") + public int getAttemptNumber() { + return attemptNumber; + } + + /** + * @return Time of the delivery attempt in ISO 8601 format with UTC timezone. + */ + @JsonProperty("timestamp") + public OffsetDateTime getTimestamp() { + return timestamp; + } + + /** + * @return Outcome of this delivery attempt. + */ + @JsonProperty("delivery_status") + public DeliveryStatus getDeliveryStatus() { + return deliveryStatus; + } + + /** + * @return Error detail when delivery_status is FAILED. Null on success. + */ + @JsonIgnore + public Optional getErrorMessage() { + if (errorMessage == null) { + return Optional.empty(); + } + return errorMessage; + } + + /** + * @return Non-fatal warning, such as payload truncation notices. Null when no warnings occurred. + */ + @JsonIgnore + public Optional getWarningMessage() { + if (warningMessage == null) { + return Optional.empty(); + } + return warningMessage; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("error_message") + private Optional _getErrorMessage() { + return errorMessage; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("warning_message") + private Optional _getWarningMessage() { + return warningMessage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeliveryHistoryItemDto && equalTo((DeliveryHistoryItemDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeliveryHistoryItemDto other) { + return id == other.id + && webhookId.equals(other.webhookId) + && resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && additionalInfo.equals(other.additionalInfo) + && statusCode == other.statusCode + && attemptNumber == other.attemptNumber + && timestamp.equals(other.timestamp) + && deliveryStatus.equals(other.deliveryStatus) + && errorMessage.equals(other.errorMessage) + && warningMessage.equals(other.warningMessage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.webhookId, + this.resourceType, + this.resourceId, + this.additionalInfo, + this.statusCode, + this.attemptNumber, + this.timestamp, + this.deliveryStatus, + this.errorMessage, + this.warningMessage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + *

Delivery record identifier.

+ */ + WebhookIdStage id(int id); + + Builder from(DeliveryHistoryItemDto other); + } + + public interface WebhookIdStage { + /** + *

Identifier of the webhook that was dispatched.

+ */ + ResourceTypeStage webhookId(@NotNull String webhookId); + } + + public interface ResourceTypeStage { + /** + *

Type of the resource that triggered the delivery.

+ */ + ResourceIdStage resourceType(@NotNull MappableResourceType resourceType); + } + + public interface ResourceIdStage { + /** + *

Identifier of the resource that triggered the delivery.

+ */ + StatusCodeStage resourceId(@NotNull String resourceId); + } + + public interface StatusCodeStage { + /** + *

HTTP response code returned by the webhook endpoint.

+ */ + AttemptNumberStage statusCode(int statusCode); + } + + public interface AttemptNumberStage { + /** + *

Delivery attempt number. 1 indicates the first attempt.

+ */ + TimestampStage attemptNumber(int attemptNumber); + } + + public interface TimestampStage { + /** + *

Time of the delivery attempt in ISO 8601 format with UTC timezone.

+ */ + DeliveryStatusStage timestamp(@NotNull OffsetDateTime timestamp); + } + + public interface DeliveryStatusStage { + /** + *

Outcome of this delivery attempt.

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

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

+ */ + _FinalStage additionalInfo(Optional> additionalInfo); + + _FinalStage additionalInfo(Map additionalInfo); + + /** + *

Error detail when delivery_status is FAILED. Null on success.

+ */ + _FinalStage errorMessage(Optional errorMessage); + + _FinalStage errorMessage(String errorMessage); + + _FinalStage errorMessage(Nullable errorMessage); + + /** + *

Non-fatal warning, such as payload truncation notices. Null when no warnings occurred.

+ */ + _FinalStage warningMessage(Optional warningMessage); + + _FinalStage warningMessage(String warningMessage); + + _FinalStage warningMessage(Nullable warningMessage); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + WebhookIdStage, + ResourceTypeStage, + ResourceIdStage, + StatusCodeStage, + AttemptNumberStage, + TimestampStage, + DeliveryStatusStage, + _FinalStage { + private int id; + + private String webhookId; + + private MappableResourceType resourceType; + + private String resourceId; + + private int statusCode; + + private int attemptNumber; + + private OffsetDateTime timestamp; + + private DeliveryStatus deliveryStatus; + + private Optional warningMessage = Optional.empty(); + + private Optional errorMessage = Optional.empty(); + + private Optional> additionalInfo = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeliveryHistoryItemDto other) { + id(other.getId()); + webhookId(other.getWebhookId()); + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + additionalInfo(other.getAdditionalInfo()); + statusCode(other.getStatusCode()); + attemptNumber(other.getAttemptNumber()); + timestamp(other.getTimestamp()); + deliveryStatus(other.getDeliveryStatus()); + errorMessage(other.getErrorMessage()); + warningMessage(other.getWarningMessage()); + return this; + } + + /** + *

Delivery record identifier.

+ *

Delivery record identifier.

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

Identifier of the webhook that was dispatched.

+ *

Identifier of the webhook that was dispatched.

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

Type of the resource that triggered the delivery.

+ *

Type of the resource that triggered the delivery.

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

Identifier of the resource that triggered the delivery.

+ *

Identifier of the resource that triggered the delivery.

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

HTTP response code returned by the webhook endpoint.

+ *

HTTP response code returned by the webhook endpoint.

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

Delivery attempt number. 1 indicates the first attempt.

+ *

Delivery attempt number. 1 indicates the first attempt.

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

Time of the delivery attempt in ISO 8601 format with UTC timezone.

+ *

Time of the delivery attempt in ISO 8601 format with UTC timezone.

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

Outcome of this delivery attempt.

+ *

Outcome of this delivery attempt.

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

Non-fatal warning, such as payload truncation notices. Null when no warnings occurred.

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

Non-fatal warning, such as payload truncation notices. Null when no warnings occurred.

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

Non-fatal warning, such as payload truncation notices. Null when no warnings occurred.

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

Error detail when delivery_status is FAILED. Null on success.

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

Error detail when delivery_status is FAILED. Null on success.

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

Error detail when delivery_status is FAILED. Null on success.

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

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

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

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

+ */ + @java.lang.Override + @JsonSetter(value = "additional_info", nulls = Nulls.SKIP) + public _FinalStage additionalInfo(Optional> additionalInfo) { + this.additionalInfo = additionalInfo; + return this; + } + + @java.lang.Override + public DeliveryHistoryItemDto build() { + return new DeliveryHistoryItemDto( + id, + webhookId, + resourceType, + resourceId, + additionalInfo, + statusCode, + attemptNumber, + timestamp, + deliveryStatus, + errorMessage, + warningMessage, + 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/DeliveryHistoryResponseDto.java b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryResponseDto.java new file mode 100644 index 0000000..5c638b8 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/DeliveryHistoryResponseDto.java @@ -0,0 +1,378 @@ +/** + * 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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeliveryHistoryResponseDto.Builder.class) +public final class DeliveryHistoryResponseDto { + private final MappableResourceType resourceType; + + private final String resourceId; + + private final int total; + + private final int page; + + private final int pageSize; + + private final int totalPages; + + private final List items; + + private final Map additionalProperties; + + private DeliveryHistoryResponseDto( + MappableResourceType resourceType, + String resourceId, + int total, + int page, + int pageSize, + int totalPages, + List items, + Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.totalPages = totalPages; + this.items = items; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of the queried resource. + */ + @JsonProperty("resource_type") + public MappableResourceType getResourceType() { + return resourceType; + } + + /** + * @return Identifier of the queried resource. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return Total number of delivery records for this resource. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return Current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return Number of records per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + /** + * @return Total number of pages available. + */ + @JsonProperty("total_pages") + public int getTotalPages() { + return totalPages; + } + + /** + * @return Delivery records on this page, ordered by timestamp descending. + */ + @JsonProperty("items") + public List getItems() { + return items; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeliveryHistoryResponseDto && equalTo((DeliveryHistoryResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeliveryHistoryResponseDto other) { + return resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && total == other.total + && page == other.page + && pageSize == other.pageSize + && totalPages == other.totalPages + && items.equals(other.items); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.resourceType, this.resourceId, this.total, this.page, this.pageSize, this.totalPages, this.items); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + /** + *

Type of the queried resource.

+ */ + ResourceIdStage resourceType(@NotNull MappableResourceType resourceType); + + Builder from(DeliveryHistoryResponseDto other); + } + + public interface ResourceIdStage { + /** + *

Identifier of the queried resource.

+ */ + TotalStage resourceId(@NotNull String resourceId); + } + + public interface TotalStage { + /** + *

Total number of delivery records for this resource.

+ */ + PageStage total(int total); + } + + public interface PageStage { + /** + *

Current page number.

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

Number of records per page.

+ */ + TotalPagesStage pageSize(int pageSize); + } + + public interface TotalPagesStage { + /** + *

Total number of pages available.

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

Delivery records on this page, ordered by timestamp descending.

+ */ + _FinalStage items(List items); + + _FinalStage addItems(DeliveryHistoryItemDto items); + + _FinalStage addAllItems(List items); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements ResourceTypeStage, + ResourceIdStage, + TotalStage, + PageStage, + PageSizeStage, + TotalPagesStage, + _FinalStage { + private MappableResourceType resourceType; + + private String resourceId; + + private int total; + + private int page; + + private int pageSize; + + private int totalPages; + + private List items = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeliveryHistoryResponseDto other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + totalPages(other.getTotalPages()); + items(other.getItems()); + return this; + } + + /** + *

Type of the queried resource.

+ *

Type of the queried resource.

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

Identifier of the queried resource.

+ *

Identifier of the queried resource.

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

Total number of delivery records for this resource.

+ *

Total number of delivery records for this resource.

+ * @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; + } + + /** + *

Current page number.

+ *

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; + } + + /** + *

Number of records per page.

+ *

Number of records per page.

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

Total number of pages available.

+ *

Total number of pages available.

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

Delivery records on this page, ordered by timestamp descending.

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

Delivery records on this page, ordered by timestamp descending.

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

Delivery records on this page, ordered by timestamp descending.

+ */ + @java.lang.Override + @JsonSetter(value = "items", nulls = Nulls.SKIP) + public _FinalStage items(List items) { + this.items.clear(); + if (items != null) { + this.items.addAll(items); + } + return this; + } + + @java.lang.Override + public DeliveryHistoryResponseDto build() { + return new DeliveryHistoryResponseDto( + resourceType, resourceId, total, page, pageSize, totalPages, items, 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/DeliveryMode.java b/src/main/java/com/newscatcher/catchall/types/DeliveryMode.java new file mode 100644 index 0000000..1c896e1 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/DeliveryMode.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DeliveryMode { + public static final DeliveryMode FULL = new DeliveryMode(Value.FULL, "full"); + + public static final DeliveryMode PER_RECORD = new DeliveryMode(Value.PER_RECORD, "per_record"); + + private final Value value; + + private final String string; + + DeliveryMode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof DeliveryMode && this.string.equals(((DeliveryMode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FULL: + return visitor.visitFull(); + case PER_RECORD: + return visitor.visitPerRecord(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeliveryMode valueOf(String value) { + switch (value) { + case "full": + return FULL; + case "per_record": + return PER_RECORD; + default: + return new DeliveryMode(Value.UNKNOWN, value); + } + } + + public enum Value { + FULL, + + PER_RECORD, + + UNKNOWN + } + + public interface Visitor { + T visitFull(); + + T visitPerRecord(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/DeliveryStatus.java b/src/main/java/com/newscatcher/catchall/types/DeliveryStatus.java new file mode 100644 index 0000000..a1b9915 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/DeliveryStatus.java @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DeliveryStatus { + public static final DeliveryStatus SUCCESS = new DeliveryStatus(Value.SUCCESS, "SUCCESS"); + + public static final DeliveryStatus FAILED = new DeliveryStatus(Value.FAILED, "FAILED"); + + private final Value value; + + private final String string; + + DeliveryStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof DeliveryStatus && this.string.equals(((DeliveryStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SUCCESS: + return visitor.visitSuccess(); + case FAILED: + return visitor.visitFailed(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeliveryStatus valueOf(String value) { + switch (value) { + case "SUCCESS": + return SUCCESS; + case "FAILED": + return FAILED; + default: + return new DeliveryStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + SUCCESS, + + FAILED, + + UNKNOWN + } + + public interface Visitor { + T visitSuccess(); + + T visitFailed(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/GetWebhookResponseDto.java b/src/main/java/com/newscatcher/catchall/types/GetWebhookResponseDto.java new file mode 100644 index 0000000..9eda090 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/GetWebhookResponseDto.java @@ -0,0 +1,209 @@ +/** + * 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.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 = GetWebhookResponseDto.Builder.class) +public final class GetWebhookResponseDto { + private final boolean success; + + private final String message; + + private final Optional webhook; + + private final Map additionalProperties; + + private GetWebhookResponseDto( + boolean success, + String message, + Optional webhook, + Map additionalProperties) { + this.success = success; + this.message = message; + this.webhook = webhook; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return The retrieved webhook object. + */ + @JsonProperty("webhook") + public Optional getWebhook() { + return webhook; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetWebhookResponseDto && equalTo((GetWebhookResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetWebhookResponseDto other) { + return success == other.success && message.equals(other.message) && webhook.equals(other.webhook); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.webhook); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(GetWebhookResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

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

The retrieved webhook object.

+ */ + _FinalStage webhook(Optional webhook); + + _FinalStage webhook(WebhookResponseDto webhook); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + private Optional webhook = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetWebhookResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + webhook(other.getWebhook()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

The retrieved webhook object.

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

The retrieved webhook object.

+ */ + @java.lang.Override + @JsonSetter(value = "webhook", nulls = Nulls.SKIP) + public _FinalStage webhook(Optional webhook) { + this.webhook = webhook; + return this; + } + + @java.lang.Override + public GetWebhookResponseDto build() { + return new GetWebhookResponseDto(success, message, webhook, 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/HttpMethod.java b/src/main/java/com/newscatcher/catchall/types/HttpMethod.java new file mode 100644 index 0000000..f35ef0f --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/HttpMethod.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class HttpMethod { + public static final HttpMethod GET = new HttpMethod(Value.GET, "GET"); + + public static final HttpMethod PUT = new HttpMethod(Value.PUT, "PUT"); + + public static final HttpMethod PATCH = new HttpMethod(Value.PATCH, "PATCH"); + + public static final HttpMethod DELETE = new HttpMethod(Value.DELETE, "DELETE"); + + public static final HttpMethod POST = new HttpMethod(Value.POST, "POST"); + + private final Value value; + + private final String string; + + HttpMethod(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof HttpMethod && this.string.equals(((HttpMethod) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case GET: + return visitor.visitGet(); + case PUT: + return visitor.visitPut(); + case PATCH: + return visitor.visitPatch(); + case DELETE: + return visitor.visitDelete(); + case POST: + return visitor.visitPost(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static HttpMethod valueOf(String value) { + switch (value) { + case "GET": + return GET; + case "PUT": + return PUT; + case "PATCH": + return PATCH; + case "DELETE": + return DELETE; + case "POST": + return POST; + default: + return new HttpMethod(Value.UNKNOWN, value); + } + } + + public enum Value { + GET, + + POST, + + PUT, + + PATCH, + + DELETE, + + UNKNOWN + } + + public interface Visitor { + T visitGet(); + + T visitPost(); + + T visitPut(); + + T visitPatch(); + + T visitDelete(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/IssueType.java b/src/main/java/com/newscatcher/catchall/types/IssueType.java new file mode 100644 index 0000000..4f9b7c9 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/IssueType.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class IssueType { + public static final IssueType MISSING_EVENT_TYPE = new IssueType(Value.MISSING_EVENT_TYPE, "missing_event_type"); + + public static final IssueType TOO_SHORT = new IssueType(Value.TOO_SHORT, "too_short"); + + public static final IssueType TOO_LONG = new IssueType(Value.TOO_LONG, "too_long"); + + public static final IssueType ARTICLE_REQUEST = new IssueType(Value.ARTICLE_REQUEST, "article_request"); + + public static final IssueType TOO_VAGUE = new IssueType(Value.TOO_VAGUE, "too_vague"); + + public static final IssueType STATIC_CONTENT = new IssueType(Value.STATIC_CONTENT, "static_content"); + + public static final IssueType MULTIPLE_EVENT_TYPES = + new IssueType(Value.MULTIPLE_EVENT_TYPES, "multiple_event_types"); + + public static final IssueType TOO_SPECIFIC = new IssueType(Value.TOO_SPECIFIC, "too_specific"); + + public static final IssueType WRONG_TIMEFRAME = new IssueType(Value.WRONG_TIMEFRAME, "wrong_timeframe"); + + private final Value value; + + private final String string; + + IssueType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof IssueType && this.string.equals(((IssueType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MISSING_EVENT_TYPE: + return visitor.visitMissingEventType(); + case TOO_SHORT: + return visitor.visitTooShort(); + case TOO_LONG: + return visitor.visitTooLong(); + case ARTICLE_REQUEST: + return visitor.visitArticleRequest(); + case TOO_VAGUE: + return visitor.visitTooVague(); + case STATIC_CONTENT: + return visitor.visitStaticContent(); + case MULTIPLE_EVENT_TYPES: + return visitor.visitMultipleEventTypes(); + case TOO_SPECIFIC: + return visitor.visitTooSpecific(); + case WRONG_TIMEFRAME: + return visitor.visitWrongTimeframe(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static IssueType valueOf(String value) { + switch (value) { + case "missing_event_type": + return MISSING_EVENT_TYPE; + case "too_short": + return TOO_SHORT; + case "too_long": + return TOO_LONG; + case "article_request": + return ARTICLE_REQUEST; + case "too_vague": + return TOO_VAGUE; + case "static_content": + return STATIC_CONTENT; + case "multiple_event_types": + return MULTIPLE_EVENT_TYPES; + case "too_specific": + return TOO_SPECIFIC; + case "wrong_timeframe": + return WRONG_TIMEFRAME; + default: + return new IssueType(Value.UNKNOWN, value); + } + } + + public enum Value { + MISSING_EVENT_TYPE, + + TOO_VAGUE, + + TOO_SPECIFIC, + + WRONG_TIMEFRAME, + + STATIC_CONTENT, + + ARTICLE_REQUEST, + + MULTIPLE_EVENT_TYPES, + + TOO_SHORT, + + TOO_LONG, + + UNKNOWN + } + + public interface Visitor { + T visitMissingEventType(); + + T visitTooVague(); + + T visitTooSpecific(); + + T visitWrongTimeframe(); + + T visitStaticContent(); + + T visitArticleRequest(); + + T visitMultipleEventTypes(); + + T visitTooShort(); + + T visitTooLong(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/JobStep.java b/src/main/java/com/newscatcher/catchall/types/JobStep.java index 7b53bd7..3674f56 100644 --- a/src/main/java/com/newscatcher/catchall/types/JobStep.java +++ b/src/main/java/com/newscatcher/catchall/types/JobStep.java @@ -48,7 +48,7 @@ public int getOrder() { } /** - * @return Whether this step has finished processing. + * @return True if this step has finished processing; false otherwise. */ @JsonProperty("completed") public boolean getCompleted() { @@ -99,7 +99,7 @@ public interface OrderStage { public interface CompletedStage { /** - *

Whether this step has finished processing.

+ *

True if this step has finished processing; false otherwise.

*/ _FinalStage completed(boolean completed); } @@ -153,8 +153,8 @@ public CompletedStage order(int order) { } /** - *

Whether this step has finished processing.

- *

Whether this step has finished processing.

+ *

True if this step has finished processing; false otherwise.

+ *

True if this step has finished processing; false otherwise.

* @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/ListWebhookResourcesResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ListWebhookResourcesResponseDto.java new file mode 100644 index 0000000..cff1bfa --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ListWebhookResourcesResponseDto.java @@ -0,0 +1,299 @@ +/** + * 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 = ListWebhookResourcesResponseDto.Builder.class) +public final class ListWebhookResourcesResponseDto { + private final int total; + + private final int page; + + private final int pageSize; + + private final int totalPages; + + private final List resources; + + private final Map additionalProperties; + + private ListWebhookResourcesResponseDto( + int total, + int page, + int pageSize, + int totalPages, + List resources, + Map additionalProperties) { + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.totalPages = totalPages; + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + /** + * @return Total number of resource mappings for this webhook. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return Current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return Number of mappings per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + /** + * @return Total number of pages available. + */ + @JsonProperty("total_pages") + public int getTotalPages() { + return totalPages; + } + + /** + * @return Resource mappings on this page. + */ + @JsonProperty("resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListWebhookResourcesResponseDto && equalTo((ListWebhookResourcesResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListWebhookResourcesResponseDto other) { + return total == other.total + && page == other.page + && pageSize == other.pageSize + && totalPages == other.totalPages + && resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.total, this.page, this.pageSize, this.totalPages, this.resources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalStage builder() { + return new Builder(); + } + + public interface TotalStage { + /** + *

Total number of resource mappings for this webhook.

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

Current page number.

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

Number of mappings per page.

+ */ + TotalPagesStage pageSize(int pageSize); + } + + public interface TotalPagesStage { + /** + *

Total number of pages available.

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

Resource mappings on this page.

+ */ + _FinalStage resources(List resources); + + _FinalStage addResources(WebhookResourceMappingResponseDto resources); + + _FinalStage addAllResources(List resources); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalStage, PageStage, PageSizeStage, TotalPagesStage, _FinalStage { + private int total; + + private int page; + + private int pageSize; + + private int totalPages; + + private List resources = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListWebhookResourcesResponseDto other) { + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + totalPages(other.getTotalPages()); + resources(other.getResources()); + return this; + } + + /** + *

Total number of resource mappings for this webhook.

+ *

Total number of resource mappings for this webhook.

+ * @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; + } + + /** + *

Current page number.

+ *

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; + } + + /** + *

Number of mappings per page.

+ *

Number of mappings per page.

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

Total number of pages available.

+ *

Total number of pages available.

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

Resource mappings on this page.

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

Resource mappings on this page.

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

Resource mappings on this page.

+ */ + @java.lang.Override + @JsonSetter(value = "resources", nulls = Nulls.SKIP) + public _FinalStage resources(List resources) { + this.resources.clear(); + if (resources != null) { + this.resources.addAll(resources); + } + return this; + } + + @java.lang.Override + public ListWebhookResourcesResponseDto build() { + return new ListWebhookResourcesResponseDto( + total, page, pageSize, totalPages, resources, 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/ListWebhooksResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ListWebhooksResponseDto.java new file mode 100644 index 0000000..37658e0 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ListWebhooksResponseDto.java @@ -0,0 +1,298 @@ +/** + * 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 = ListWebhooksResponseDto.Builder.class) +public final class ListWebhooksResponseDto { + private final int total; + + private final int page; + + private final int pageSize; + + private final int totalPages; + + private final List webhooks; + + private final Map additionalProperties; + + private ListWebhooksResponseDto( + int total, + int page, + int pageSize, + int totalPages, + List webhooks, + Map additionalProperties) { + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.totalPages = totalPages; + this.webhooks = webhooks; + this.additionalProperties = additionalProperties; + } + + /** + * @return Total number of webhooks in the organization. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return Current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return Number of webhooks per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + /** + * @return Total number of pages available. + */ + @JsonProperty("total_pages") + public int getTotalPages() { + return totalPages; + } + + /** + * @return Webhooks on this page. + */ + @JsonProperty("webhooks") + public List getWebhooks() { + return webhooks; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListWebhooksResponseDto && equalTo((ListWebhooksResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListWebhooksResponseDto other) { + return total == other.total + && page == other.page + && pageSize == other.pageSize + && totalPages == other.totalPages + && webhooks.equals(other.webhooks); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.total, this.page, this.pageSize, this.totalPages, this.webhooks); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalStage builder() { + return new Builder(); + } + + public interface TotalStage { + /** + *

Total number of webhooks in the organization.

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

Current page number.

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

Number of webhooks per page.

+ */ + TotalPagesStage pageSize(int pageSize); + } + + public interface TotalPagesStage { + /** + *

Total number of pages available.

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

Webhooks on this page.

+ */ + _FinalStage webhooks(List webhooks); + + _FinalStage addWebhooks(WebhookResponseDto webhooks); + + _FinalStage addAllWebhooks(List webhooks); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalStage, PageStage, PageSizeStage, TotalPagesStage, _FinalStage { + private int total; + + private int page; + + private int pageSize; + + private int totalPages; + + private List webhooks = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListWebhooksResponseDto other) { + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + totalPages(other.getTotalPages()); + webhooks(other.getWebhooks()); + return this; + } + + /** + *

Total number of webhooks in the organization.

+ *

Total number of webhooks in the 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; + } + + /** + *

Current page number.

+ *

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; + } + + /** + *

Number of webhooks per page.

+ *

Number of webhooks per page.

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

Total number of pages available.

+ *

Total number of pages available.

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

Webhooks on this page.

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

Webhooks on this page.

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

Webhooks on this page.

+ */ + @java.lang.Override + @JsonSetter(value = "webhooks", nulls = Nulls.SKIP) + public _FinalStage webhooks(List webhooks) { + this.webhooks.clear(); + if (webhooks != null) { + this.webhooks.addAll(webhooks); + } + return this; + } + + @java.lang.Override + public ListWebhooksResponseDto build() { + return new ListWebhooksResponseDto(total, page, pageSize, totalPages, webhooks, 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/MappableResourceType.java b/src/main/java/com/newscatcher/catchall/types/MappableResourceType.java new file mode 100644 index 0000000..b9bed84 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/MappableResourceType.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class MappableResourceType { + public static final MappableResourceType MONITOR = new MappableResourceType(Value.MONITOR, "monitor"); + + public static final MappableResourceType JOB = new MappableResourceType(Value.JOB, "job"); + + public static final MappableResourceType MONITOR_GROUP = + new MappableResourceType(Value.MONITOR_GROUP, "monitor_group"); + + private final Value value; + + private final String string; + + MappableResourceType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof MappableResourceType && this.string.equals(((MappableResourceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MONITOR: + return visitor.visitMonitor(); + case JOB: + return visitor.visitJob(); + case MONITOR_GROUP: + return visitor.visitMonitorGroup(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static MappableResourceType valueOf(String value) { + switch (value) { + case "monitor": + return MONITOR; + case "job": + return JOB; + case "monitor_group": + return MONITOR_GROUP; + default: + return new MappableResourceType(Value.UNKNOWN, value); + } + } + + public enum Value { + JOB, + + MONITOR, + + MONITOR_GROUP, + + UNKNOWN + } + + public interface Visitor { + T visitJob(); + + T visitMonitor(); + + T visitMonitorGroup(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java b/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java index d3deb2a..88668e3 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorListItemDto.java @@ -101,7 +101,7 @@ public String getReferenceJobQuery() { } /** - * @return Whether the monitor is currently active. + * @return True if the monitor is currently active; false otherwise. */ @JsonProperty("enabled") public boolean getEnabled() { @@ -248,7 +248,7 @@ public interface ReferenceJobQueryStage { public interface EnabledStage { /** - *

Whether the monitor is currently active.

+ *

True if the monitor is currently active; false otherwise.

*/ _FinalStage enabled(boolean enabled); } @@ -395,8 +395,8 @@ public EnabledStage referenceJobQuery(@NotNull String referenceJobQuery) { } /** - *

Whether the monitor is currently active.

- *

Whether the monitor is currently active.

+ *

True if the monitor is currently active; false otherwise.

+ *

True if the monitor is currently active; false otherwise.

* @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/MonitorStatusHistoryResponseDto.java b/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java index e0cfecb..56f5f0f 100644 --- a/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java +++ b/src/main/java/com/newscatcher/catchall/types/MonitorStatusHistoryResponseDto.java @@ -52,7 +52,7 @@ private MonitorStatusHistoryResponseDto( } /** - * @return Whether the request succeeded. + * @return True if the request succeeded; false otherwise. */ @JsonProperty("success") public boolean getSuccess() { @@ -162,7 +162,7 @@ public static SuccessStage builder() { public interface SuccessStage { /** - *

Whether the request succeeded.

+ *

True if the request succeeded; false otherwise.

*/ _FinalStage success(boolean success); @@ -241,8 +241,8 @@ public Builder from(MonitorStatusHistoryResponseDto other) { } /** - *

Whether the request succeeded.

- *

Whether the request succeeded.

+ *

True if the request succeeded; false otherwise.

+ *

True if the request succeeded; false otherwise.

* @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/ProjectListResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectListResponseDto.java new file mode 100644 index 0000000..6bc1e34 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectListResponseDto.java @@ -0,0 +1,298 @@ +/** + * 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 = ProjectListResponseDto.Builder.class) +public final class ProjectListResponseDto { + private final int total; + + private final int page; + + private final int pageSize; + + private final int totalPages; + + private final List projects; + + private final Map additionalProperties; + + private ProjectListResponseDto( + int total, + int page, + int pageSize, + int totalPages, + List projects, + Map additionalProperties) { + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.totalPages = totalPages; + this.projects = projects; + this.additionalProperties = additionalProperties; + } + + /** + * @return Total number of projects matching the filter criteria. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return Current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return Number of projects per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + /** + * @return Total number of pages. + */ + @JsonProperty("total_pages") + public int getTotalPages() { + return totalPages; + } + + /** + * @return Projects on this page. + */ + @JsonProperty("projects") + public List getProjects() { + return projects; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectListResponseDto && equalTo((ProjectListResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectListResponseDto other) { + return total == other.total + && page == other.page + && pageSize == other.pageSize + && totalPages == other.totalPages + && projects.equals(other.projects); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.total, this.page, this.pageSize, this.totalPages, this.projects); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalStage builder() { + return new Builder(); + } + + public interface TotalStage { + /** + *

Total number of projects matching the filter criteria.

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

Current page number.

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

Number of projects per page.

+ */ + TotalPagesStage pageSize(int pageSize); + } + + public interface TotalPagesStage { + /** + *

Total number of pages.

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

Projects on this page.

+ */ + _FinalStage projects(List projects); + + _FinalStage addProjects(ProjectSummaryDto projects); + + _FinalStage addAllProjects(List projects); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalStage, PageStage, PageSizeStage, TotalPagesStage, _FinalStage { + private int total; + + private int page; + + private int pageSize; + + private int totalPages; + + private List projects = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectListResponseDto other) { + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + totalPages(other.getTotalPages()); + projects(other.getProjects()); + return this; + } + + /** + *

Total number of projects matching the filter criteria.

+ *

Total number of projects matching the filter criteria.

+ * @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; + } + + /** + *

Current page number.

+ *

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; + } + + /** + *

Number of projects per page.

+ *

Number of projects per page.

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

Total number of pages.

+ *

Total number of pages.

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

Projects on this page.

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

Projects on this page.

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

Projects on this page.

+ */ + @java.lang.Override + @JsonSetter(value = "projects", nulls = Nulls.SKIP) + public _FinalStage projects(List projects) { + this.projects.clear(); + if (projects != null) { + this.projects.addAll(projects); + } + return this; + } + + @java.lang.Override + public ProjectListResponseDto build() { + return new ProjectListResponseDto(total, page, pageSize, totalPages, projects, 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/ProjectOverviewResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDto.java new file mode 100644 index 0000000..2cd2707 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDto.java @@ -0,0 +1,163 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ProjectOverviewResponseDto.Builder.class) +public final class ProjectOverviewResponseDto { + private final String projectId; + + private final ProjectOverviewResponseDtoOverview overview; + + private final Map additionalProperties; + + private ProjectOverviewResponseDto( + String projectId, ProjectOverviewResponseDtoOverview overview, Map additionalProperties) { + this.projectId = projectId; + this.overview = overview; + this.additionalProperties = additionalProperties; + } + + /** + * @return Project identifier. + */ + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + + /** + * @return Resource counts grouped by type. + */ + @JsonProperty("overview") + public ProjectOverviewResponseDtoOverview getOverview() { + return overview; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectOverviewResponseDto && equalTo((ProjectOverviewResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectOverviewResponseDto other) { + return projectId.equals(other.projectId) && overview.equals(other.overview); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.projectId, this.overview); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProjectIdStage builder() { + return new Builder(); + } + + public interface ProjectIdStage { + /** + *

Project identifier.

+ */ + OverviewStage projectId(@NotNull String projectId); + + Builder from(ProjectOverviewResponseDto other); + } + + public interface OverviewStage { + /** + *

Resource counts grouped by type.

+ */ + _FinalStage overview(@NotNull ProjectOverviewResponseDtoOverview overview); + } + + public interface _FinalStage { + ProjectOverviewResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProjectIdStage, OverviewStage, _FinalStage { + private String projectId; + + private ProjectOverviewResponseDtoOverview overview; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectOverviewResponseDto other) { + projectId(other.getProjectId()); + overview(other.getOverview()); + return this; + } + + /** + *

Project identifier.

+ *

Project identifier.

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

Resource counts grouped by type.

+ *

Resource counts grouped by type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("overview") + public _FinalStage overview(@NotNull ProjectOverviewResponseDtoOverview overview) { + this.overview = Objects.requireNonNull(overview, "overview must not be null"); + return this; + } + + @java.lang.Override + public ProjectOverviewResponseDto build() { + return new ProjectOverviewResponseDto(projectId, overview, 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/ProjectOverviewResponseDtoOverview.java b/src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDtoOverview.java new file mode 100644 index 0000000..e8bb09b --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectOverviewResponseDtoOverview.java @@ -0,0 +1,221 @@ +/** + * 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.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ProjectOverviewResponseDtoOverview.Builder.class) +public final class ProjectOverviewResponseDtoOverview { + private final Map jobs; + + private final Map monitors; + + private final Map datasets; + + private final Map monitorGroups; + + private final Map additionalProperties; + + private ProjectOverviewResponseDtoOverview( + Map jobs, + Map monitors, + Map datasets, + Map monitorGroups, + Map additionalProperties) { + this.jobs = jobs; + this.monitors = monitors; + this.datasets = datasets; + this.monitorGroups = monitorGroups; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("jobs") + public Map getJobs() { + return jobs; + } + + @JsonProperty("monitors") + public Map getMonitors() { + return monitors; + } + + @JsonProperty("datasets") + public Map getDatasets() { + return datasets; + } + + @JsonProperty("monitor_groups") + public Map getMonitorGroups() { + return monitorGroups; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectOverviewResponseDtoOverview + && equalTo((ProjectOverviewResponseDtoOverview) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectOverviewResponseDtoOverview other) { + return jobs.equals(other.jobs) + && monitors.equals(other.monitors) + && datasets.equals(other.datasets) + && monitorGroups.equals(other.monitorGroups); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobs, this.monitors, this.datasets, this.monitorGroups); + } + + @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 Map jobs = new LinkedHashMap<>(); + + private Map monitors = new LinkedHashMap<>(); + + private Map datasets = new LinkedHashMap<>(); + + private Map monitorGroups = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ProjectOverviewResponseDtoOverview other) { + jobs(other.getJobs()); + monitors(other.getMonitors()); + datasets(other.getDatasets()); + monitorGroups(other.getMonitorGroups()); + return this; + } + + @JsonSetter(value = "jobs", nulls = Nulls.SKIP) + public Builder jobs(Map jobs) { + this.jobs.clear(); + if (jobs != null) { + this.jobs.putAll(jobs); + } + return this; + } + + public Builder putAllJobs(Map jobs) { + if (jobs != null) { + this.jobs.putAll(jobs); + } + return this; + } + + public Builder jobs(String key, Object value) { + this.jobs.put(key, value); + return this; + } + + @JsonSetter(value = "monitors", nulls = Nulls.SKIP) + public Builder monitors(Map monitors) { + this.monitors.clear(); + if (monitors != null) { + this.monitors.putAll(monitors); + } + return this; + } + + public Builder putAllMonitors(Map monitors) { + if (monitors != null) { + this.monitors.putAll(monitors); + } + return this; + } + + public Builder monitors(String key, Object value) { + this.monitors.put(key, value); + return this; + } + + @JsonSetter(value = "datasets", nulls = Nulls.SKIP) + public Builder datasets(Map datasets) { + this.datasets.clear(); + if (datasets != null) { + this.datasets.putAll(datasets); + } + return this; + } + + public Builder putAllDatasets(Map datasets) { + if (datasets != null) { + this.datasets.putAll(datasets); + } + return this; + } + + public Builder datasets(String key, Object value) { + this.datasets.put(key, value); + return this; + } + + @JsonSetter(value = "monitor_groups", nulls = Nulls.SKIP) + public Builder monitorGroups(Map monitorGroups) { + this.monitorGroups.clear(); + if (monitorGroups != null) { + this.monitorGroups.putAll(monitorGroups); + } + return this; + } + + public Builder putAllMonitorGroups(Map monitorGroups) { + if (monitorGroups != null) { + this.monitorGroups.putAll(monitorGroups); + } + return this; + } + + public Builder monitorGroups(String key, Object value) { + this.monitorGroups.put(key, value); + return this; + } + + public ProjectOverviewResponseDtoOverview build() { + return new ProjectOverviewResponseDtoOverview( + jobs, monitors, datasets, monitorGroups, 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/ProjectResourceDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectResourceDto.java new file mode 100644 index 0000000..910e135 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectResourceDto.java @@ -0,0 +1,291 @@ +/** + * 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.time.OffsetDateTime; +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 = ProjectResourceDto.Builder.class) +public final class ProjectResourceDto { + private final ProjectResourceType resourceType; + + private final String resourceId; + + private final Optional name; + + private final Optional createdAt; + + private final Optional> metadata; + + private final Map additionalProperties; + + private ProjectResourceDto( + ProjectResourceType resourceType, + String resourceId, + Optional name, + Optional createdAt, + Optional> metadata, + Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.name = name; + this.createdAt = createdAt; + this.metadata = metadata; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resource_type") + public ProjectResourceType getResourceType() { + return resourceType; + } + + /** + * @return Resource identifier. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return Resource display name. For jobs, this is the original query + * string. For monitors and datasets, this is the resource name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Resource creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Additional resource-specific metadata. + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectResourceDto && equalTo((ProjectResourceDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectResourceDto other) { + return resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && name.equals(other.name) + && createdAt.equals(other.createdAt) + && metadata.equals(other.metadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.resourceId, this.name, this.createdAt, this.metadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + ResourceIdStage resourceType(@NotNull ProjectResourceType resourceType); + + Builder from(ProjectResourceDto other); + } + + public interface ResourceIdStage { + /** + *

Resource identifier.

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

Resource display name. For jobs, this is the original query + * string. For monitors and datasets, this is the resource name.

+ */ + _FinalStage name(Optional name); + + _FinalStage name(String name); + + /** + *

Resource creation timestamp.

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

Additional resource-specific metadata.

+ */ + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ResourceTypeStage, ResourceIdStage, _FinalStage { + private ProjectResourceType resourceType; + + private String resourceId; + + private Optional> metadata = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectResourceDto other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + metadata(other.getMetadata()); + return this; + } + + @java.lang.Override + @JsonSetter("resource_type") + public ResourceIdStage resourceType(@NotNull ProjectResourceType resourceType) { + this.resourceType = Objects.requireNonNull(resourceType, "resourceType must not be null"); + return this; + } + + /** + *

Resource identifier.

+ *

Resource identifier.

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

Additional resource-specific metadata.

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

Additional resource-specific metadata.

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

Resource creation timestamp.

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

Resource creation timestamp.

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

Resource display name. For jobs, this is the original query + * string. For monitors and datasets, this is the resource name.

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

Resource display name. For jobs, this is the original query + * string. For monitors and datasets, this is the resource name.

+ */ + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public ProjectResourceDto build() { + return new ProjectResourceDto(resourceType, resourceId, name, createdAt, metadata, 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/ProjectResourceListResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectResourceListResponseDto.java new file mode 100644 index 0000000..7a92430 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectResourceListResponseDto.java @@ -0,0 +1,299 @@ +/** + * 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 = ProjectResourceListResponseDto.Builder.class) +public final class ProjectResourceListResponseDto { + private final int total; + + private final int page; + + private final int pageSize; + + private final int totalPages; + + private final List resources; + + private final Map additionalProperties; + + private ProjectResourceListResponseDto( + int total, + int page, + int pageSize, + int totalPages, + List resources, + Map additionalProperties) { + this.total = total; + this.page = page; + this.pageSize = pageSize; + this.totalPages = totalPages; + this.resources = resources; + this.additionalProperties = additionalProperties; + } + + /** + * @return Total number of resources assigned to the project. + */ + @JsonProperty("total") + public int getTotal() { + return total; + } + + /** + * @return Current page number. + */ + @JsonProperty("page") + public int getPage() { + return page; + } + + /** + * @return Number of resources per page. + */ + @JsonProperty("page_size") + public int getPageSize() { + return pageSize; + } + + /** + * @return Total number of pages. + */ + @JsonProperty("total_pages") + public int getTotalPages() { + return totalPages; + } + + /** + * @return Resources on this page. + */ + @JsonProperty("resources") + public List getResources() { + return resources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ProjectResourceListResponseDto && equalTo((ProjectResourceListResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectResourceListResponseDto other) { + return total == other.total + && page == other.page + && pageSize == other.pageSize + && totalPages == other.totalPages + && resources.equals(other.resources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.total, this.page, this.pageSize, this.totalPages, this.resources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TotalStage builder() { + return new Builder(); + } + + public interface TotalStage { + /** + *

Total number of resources assigned to the project.

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

Current page number.

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

Number of resources per page.

+ */ + TotalPagesStage pageSize(int pageSize); + } + + public interface TotalPagesStage { + /** + *

Total number of pages.

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

Resources on this page.

+ */ + _FinalStage resources(List resources); + + _FinalStage addResources(ProjectResourceDto resources); + + _FinalStage addAllResources(List resources); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TotalStage, PageStage, PageSizeStage, TotalPagesStage, _FinalStage { + private int total; + + private int page; + + private int pageSize; + + private int totalPages; + + private List resources = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectResourceListResponseDto other) { + total(other.getTotal()); + page(other.getPage()); + pageSize(other.getPageSize()); + totalPages(other.getTotalPages()); + resources(other.getResources()); + return this; + } + + /** + *

Total number of resources assigned to the project.

+ *

Total number of resources assigned to the project.

+ * @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; + } + + /** + *

Current page number.

+ *

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; + } + + /** + *

Number of resources per page.

+ *

Number of resources per page.

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

Total number of pages.

+ *

Total number of pages.

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

Resources on this page.

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

Resources on this page.

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

Resources on this page.

+ */ + @java.lang.Override + @JsonSetter(value = "resources", nulls = Nulls.SKIP) + public _FinalStage resources(List resources) { + this.resources.clear(); + if (resources != null) { + this.resources.addAll(resources); + } + return this; + } + + @java.lang.Override + public ProjectResourceListResponseDto build() { + return new ProjectResourceListResponseDto( + total, page, pageSize, totalPages, resources, 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/ProjectResourceType.java b/src/main/java/com/newscatcher/catchall/types/ProjectResourceType.java new file mode 100644 index 0000000..8d0fd1d --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectResourceType.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ProjectResourceType { + public static final ProjectResourceType MONITOR = new ProjectResourceType(Value.MONITOR, "monitor"); + + public static final ProjectResourceType JOB = new ProjectResourceType(Value.JOB, "job"); + + public static final ProjectResourceType DATASET = new ProjectResourceType(Value.DATASET, "dataset"); + + public static final ProjectResourceType MONITOR_GROUP = + new ProjectResourceType(Value.MONITOR_GROUP, "monitor_group"); + + private final Value value; + + private final String string; + + ProjectResourceType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ProjectResourceType && this.string.equals(((ProjectResourceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MONITOR: + return visitor.visitMonitor(); + case JOB: + return visitor.visitJob(); + case DATASET: + return visitor.visitDataset(); + case MONITOR_GROUP: + return visitor.visitMonitorGroup(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ProjectResourceType valueOf(String value) { + switch (value) { + case "monitor": + return MONITOR; + case "job": + return JOB; + case "dataset": + return DATASET; + case "monitor_group": + return MONITOR_GROUP; + default: + return new ProjectResourceType(Value.UNKNOWN, value); + } + } + + public enum Value { + JOB, + + MONITOR, + + DATASET, + + MONITOR_GROUP, + + UNKNOWN + } + + public interface Visitor { + T visitJob(); + + T visitMonitor(); + + T visitDataset(); + + T visitMonitorGroup(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/ProjectResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectResponseDto.java new file mode 100644 index 0000000..237358f --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectResponseDto.java @@ -0,0 +1,458 @@ +/** + * 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.time.OffsetDateTime; +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 = ProjectResponseDto.Builder.class) +public final class ProjectResponseDto { + private final boolean success; + + private final String message; + + private final String projectId; + + private final String name; + + private final Optional description; + + private final Optional resourcesCount; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private ProjectResponseDto( + boolean success, + String message, + String projectId, + String name, + Optional description, + Optional resourcesCount, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.success = success; + this.message = message; + this.projectId = projectId; + this.name = name; + this.description = description; + this.resourcesCount = resourcesCount; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Project identifier. + */ + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + + /** + * @return Project name. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Project description. + */ + @JsonIgnore + public Optional getDescription() { + if (description == null) { + return Optional.empty(); + } + return description; + } + + /** + * @return Number of resources assigned to this project. + */ + @JsonProperty("resources_count") + public Optional getResourcesCount() { + return resourcesCount; + } + + /** + * @return Project creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp of the last update. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @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 ProjectResponseDto && equalTo((ProjectResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectResponseDto other) { + return success == other.success + && message.equals(other.message) + && projectId.equals(other.projectId) + && name.equals(other.name) + && description.equals(other.description) + && resourcesCount.equals(other.resourcesCount) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.success, + this.message, + this.projectId, + this.name, + this.description, + this.resourcesCount, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(ProjectResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

+ */ + ProjectIdStage message(@NotNull String message); + } + + public interface ProjectIdStage { + /** + *

Project identifier.

+ */ + NameStage projectId(@NotNull String projectId); + } + + public interface NameStage { + /** + *

Project name.

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

Project description.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage description(Nullable description); + + /** + *

Number of resources assigned to this project.

+ */ + _FinalStage resourcesCount(Optional resourcesCount); + + _FinalStage resourcesCount(Integer resourcesCount); + + /** + *

Project creation timestamp.

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

Timestamp of the last update.

+ */ + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(OffsetDateTime updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, ProjectIdStage, NameStage, _FinalStage { + private boolean success; + + private String message; + + private String projectId; + + private String name; + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional resourcesCount = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + projectId(other.getProjectId()); + name(other.getName()); + description(other.getDescription()); + resourcesCount(other.getResourcesCount()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

Project identifier.

+ *

Project identifier.

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

Project name.

+ *

Project name.

+ * @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; + } + + /** + *

Timestamp of the last update.

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

Timestamp of the last update.

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

Project creation timestamp.

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

Project creation timestamp.

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

Number of resources assigned to this project.

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

Number of resources assigned to this project.

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

Project description.

+ * @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; + } + + /** + *

Project description.

+ * @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; + } + + /** + *

Project description.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public ProjectResponseDto build() { + return new ProjectResponseDto( + success, + message, + projectId, + name, + description, + resourcesCount, + createdAt, + updatedAt, + 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/ProjectSummaryDto.java b/src/main/java/com/newscatcher/catchall/types/ProjectSummaryDto.java new file mode 100644 index 0000000..20476fe --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ProjectSummaryDto.java @@ -0,0 +1,373 @@ +/** + * 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.time.OffsetDateTime; +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 = ProjectSummaryDto.Builder.class) +public final class ProjectSummaryDto { + private final String projectId; + + private final String name; + + private final Optional description; + + private final Optional resourcesCount; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private ProjectSummaryDto( + String projectId, + String name, + Optional description, + Optional resourcesCount, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.projectId = projectId; + this.name = name; + this.description = description; + this.resourcesCount = resourcesCount; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Project identifier. + */ + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + + /** + * @return Project name. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Project description. + */ + @JsonIgnore + public Optional getDescription() { + if (description == null) { + return Optional.empty(); + } + return description; + } + + /** + * @return Number of resources assigned to this project. + */ + @JsonProperty("resources_count") + public Optional getResourcesCount() { + return resourcesCount; + } + + /** + * @return Project creation timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp of the last update. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @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 ProjectSummaryDto && equalTo((ProjectSummaryDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ProjectSummaryDto other) { + return projectId.equals(other.projectId) + && name.equals(other.name) + && description.equals(other.description) + && resourcesCount.equals(other.resourcesCount) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.projectId, this.name, this.description, this.resourcesCount, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProjectIdStage builder() { + return new Builder(); + } + + public interface ProjectIdStage { + /** + *

Project identifier.

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

Project name.

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

Project description.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage description(Nullable description); + + /** + *

Number of resources assigned to this project.

+ */ + _FinalStage resourcesCount(Optional resourcesCount); + + _FinalStage resourcesCount(Integer resourcesCount); + + /** + *

Project creation timestamp.

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

Timestamp of the last update.

+ */ + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(OffsetDateTime updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProjectIdStage, NameStage, _FinalStage { + private String projectId; + + private String name; + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional resourcesCount = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ProjectSummaryDto other) { + projectId(other.getProjectId()); + name(other.getName()); + description(other.getDescription()); + resourcesCount(other.getResourcesCount()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

Project identifier.

+ *

Project identifier.

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

Project name.

+ *

Project name.

+ * @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; + } + + /** + *

Timestamp of the last update.

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

Timestamp of the last update.

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

Project creation timestamp.

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

Project creation timestamp.

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

Number of resources assigned to this project.

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

Number of resources assigned to this project.

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

Project description.

+ * @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; + } + + /** + *

Project description.

+ * @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; + } + + /** + *

Project description.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public ProjectSummaryDto build() { + return new ProjectSummaryDto( + projectId, name, description, resourcesCount, createdAt, updatedAt, 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/QueryStatus.java b/src/main/java/com/newscatcher/catchall/types/QueryStatus.java new file mode 100644 index 0000000..5c41b12 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/QueryStatus.java @@ -0,0 +1,92 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class QueryStatus { + public static final QueryStatus NEEDS_WORK = new QueryStatus(Value.NEEDS_WORK, "needs_work"); + + public static final QueryStatus CRITICAL = new QueryStatus(Value.CRITICAL, "critical"); + + public static final QueryStatus GOOD = new QueryStatus(Value.GOOD, "good"); + + private final Value value; + + private final String string; + + QueryStatus(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof QueryStatus && this.string.equals(((QueryStatus) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case NEEDS_WORK: + return visitor.visitNeedsWork(); + case CRITICAL: + return visitor.visitCritical(); + case GOOD: + return visitor.visitGood(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static QueryStatus valueOf(String value) { + switch (value) { + case "needs_work": + return NEEDS_WORK; + case "critical": + return CRITICAL; + case "good": + return GOOD; + default: + return new QueryStatus(Value.UNKNOWN, value); + } + } + + public enum Value { + GOOD, + + NEEDS_WORK, + + CRITICAL, + + UNKNOWN + } + + public interface Visitor { + T visitGood(); + + T visitNeedsWork(); + + T visitCritical(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/newscatcher/catchall/types/RemoveResourceResponseDto.java b/src/main/java/com/newscatcher/catchall/types/RemoveResourceResponseDto.java new file mode 100644 index 0000000..9801ea1 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/RemoveResourceResponseDto.java @@ -0,0 +1,162 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RemoveResourceResponseDto.Builder.class) +public final class RemoveResourceResponseDto { + private final boolean success; + + private final String message; + + private final Map additionalProperties; + + private RemoveResourceResponseDto(boolean success, String message, Map additionalProperties) { + this.success = success; + this.message = message; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RemoveResourceResponseDto && equalTo((RemoveResourceResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RemoveResourceResponseDto other) { + return success == other.success && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(RemoveResourceResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

+ */ + _FinalStage message(@NotNull String message); + } + + public interface _FinalStage { + RemoveResourceResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RemoveResourceResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("message") + public _FinalStage message(@NotNull String message) { + this.message = Objects.requireNonNull(message, "message must not be null"); + return this; + } + + @java.lang.Override + public RemoveResourceResponseDto build() { + return new RemoveResourceResponseDto(success, message, 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/ResourceItemDto.java b/src/main/java/com/newscatcher/catchall/types/ResourceItemDto.java new file mode 100644 index 0000000..d204af2 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ResourceItemDto.java @@ -0,0 +1,152 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ResourceItemDto.Builder.class) +public final class ResourceItemDto { + private final ProjectResourceType resourceType; + + private final String resourceId; + + private final Map additionalProperties; + + private ResourceItemDto( + ProjectResourceType resourceType, String resourceId, Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("resource_type") + public ProjectResourceType getResourceType() { + return resourceType; + } + + /** + * @return ID of the resource to add. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ResourceItemDto && equalTo((ResourceItemDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ResourceItemDto other) { + return resourceType.equals(other.resourceType) && resourceId.equals(other.resourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.resourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + ResourceIdStage resourceType(@NotNull ProjectResourceType resourceType); + + Builder from(ResourceItemDto other); + } + + public interface ResourceIdStage { + /** + *

ID of the resource to add.

+ */ + _FinalStage resourceId(@NotNull String resourceId); + } + + public interface _FinalStage { + ResourceItemDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ResourceTypeStage, ResourceIdStage, _FinalStage { + private ProjectResourceType resourceType; + + private String resourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ResourceItemDto other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + return this; + } + + @java.lang.Override + @JsonSetter("resource_type") + public ResourceIdStage resourceType(@NotNull ProjectResourceType resourceType) { + this.resourceType = Objects.requireNonNull(resourceType, "resourceType must not be null"); + return this; + } + + /** + *

ID of the resource to add.

+ *

ID of the resource to add.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("resource_id") + public _FinalStage resourceId(@NotNull String resourceId) { + this.resourceId = Objects.requireNonNull(resourceId, "resourceId must not be null"); + return this; + } + + @java.lang.Override + public ResourceItemDto build() { + return new ResourceItemDto(resourceType, resourceId, 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/ResourceResultDto.java b/src/main/java/com/newscatcher/catchall/types/ResourceResultDto.java new file mode 100644 index 0000000..e902599 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ResourceResultDto.java @@ -0,0 +1,283 @@ +/** + * 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.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 = ResourceResultDto.Builder.class) +public final class ResourceResultDto { + private final String resourceType; + + private final String resourceId; + + private final boolean success; + + private final String message; + + private final Optional alreadyExists; + + private final Map additionalProperties; + + private ResourceResultDto( + String resourceType, + String resourceId, + boolean success, + String message, + Optional alreadyExists, + Map additionalProperties) { + this.resourceType = resourceType; + this.resourceId = resourceId; + this.success = success; + this.message = message; + this.alreadyExists = alreadyExists; + this.additionalProperties = additionalProperties; + } + + /** + * @return Type of the resource. + */ + @JsonProperty("resource_type") + public String getResourceType() { + return resourceType; + } + + /** + * @return Resource identifier. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return True if this resource was processed successfully. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Per-resource result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return True if the resource is already assigned to this project. + */ + @JsonProperty("already_exists") + public Optional getAlreadyExists() { + return alreadyExists; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ResourceResultDto && equalTo((ResourceResultDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ResourceResultDto other) { + return resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && success == other.success + && message.equals(other.message) + && alreadyExists.equals(other.alreadyExists); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.resourceType, this.resourceId, this.success, this.message, this.alreadyExists); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ResourceTypeStage builder() { + return new Builder(); + } + + public interface ResourceTypeStage { + /** + *

Type of the resource.

+ */ + ResourceIdStage resourceType(@NotNull String resourceType); + + Builder from(ResourceResultDto other); + } + + public interface ResourceIdStage { + /** + *

Resource identifier.

+ */ + SuccessStage resourceId(@NotNull String resourceId); + } + + public interface SuccessStage { + /** + *

True if this resource was processed successfully.

+ */ + MessageStage success(boolean success); + } + + public interface MessageStage { + /** + *

Per-resource result message.

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

True if the resource is already assigned to this project.

+ */ + _FinalStage alreadyExists(Optional alreadyExists); + + _FinalStage alreadyExists(Boolean alreadyExists); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements ResourceTypeStage, ResourceIdStage, SuccessStage, MessageStage, _FinalStage { + private String resourceType; + + private String resourceId; + + private boolean success; + + private String message; + + private Optional alreadyExists = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ResourceResultDto other) { + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + success(other.getSuccess()); + message(other.getMessage()); + alreadyExists(other.getAlreadyExists()); + return this; + } + + /** + *

Type of the resource.

+ *

Type of the resource.

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

Resource identifier.

+ *

Resource identifier.

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

True if this resource was processed successfully.

+ *

True if this resource was processed successfully.

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

Per-resource result message.

+ *

Per-resource result message.

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

True if the resource is already assigned to this project.

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

True if the resource is already assigned to this project.

+ */ + @java.lang.Override + @JsonSetter(value = "already_exists", nulls = Nulls.SKIP) + public _FinalStage alreadyExists(Optional alreadyExists) { + this.alreadyExists = alreadyExists; + return this; + } + + @java.lang.Override + public ResourceResultDto build() { + return new ResourceResultDto( + resourceType, resourceId, success, message, alreadyExists, 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/Suggestion.java b/src/main/java/com/newscatcher/catchall/types/Suggestion.java new file mode 100644 index 0000000..c2bd8d9 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/Suggestion.java @@ -0,0 +1,206 @@ +/** + * 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.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 = Suggestion.Builder.class) +public final class Suggestion { + private final IssueType issue; + + private final String message; + + private final Optional example; + + private final Map additionalProperties; + + private Suggestion( + IssueType issue, String message, Optional example, Map additionalProperties) { + this.issue = issue; + this.message = message; + this.example = example; + this.additionalProperties = additionalProperties; + } + + /** + * @return The issue this suggestion addresses. + */ + @JsonProperty("issue") + public IssueType getIssue() { + return issue; + } + + /** + * @return Specific guidance for improving the query. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Revised query demonstrating the suggested improvement. + */ + @JsonProperty("example") + public Optional getExample() { + return example; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Suggestion && equalTo((Suggestion) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Suggestion other) { + return issue.equals(other.issue) && message.equals(other.message) && example.equals(other.example); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.issue, this.message, this.example); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IssueStage builder() { + return new Builder(); + } + + public interface IssueStage { + /** + *

The issue this suggestion addresses.

+ */ + MessageStage issue(@NotNull IssueType issue); + + Builder from(Suggestion other); + } + + public interface MessageStage { + /** + *

Specific guidance for improving the query.

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

Revised query demonstrating the suggested improvement.

+ */ + _FinalStage example(Optional example); + + _FinalStage example(String example); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IssueStage, MessageStage, _FinalStage { + private IssueType issue; + + private String message; + + private Optional example = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Suggestion other) { + issue(other.getIssue()); + message(other.getMessage()); + example(other.getExample()); + return this; + } + + /** + *

The issue this suggestion addresses.

+ *

The issue this suggestion addresses.

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

Specific guidance for improving the query.

+ *

Specific guidance for improving the query.

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

Revised query demonstrating the suggested improvement.

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

Revised query demonstrating the suggested improvement.

+ */ + @java.lang.Override + @JsonSetter(value = "example", nulls = Nulls.SKIP) + public _FinalStage example(Optional example) { + this.example = example; + return this; + } + + @java.lang.Override + public Suggestion build() { + return new Suggestion(issue, message, example, 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/TestWebhookResponseDto.java b/src/main/java/com/newscatcher/catchall/types/TestWebhookResponseDto.java new file mode 100644 index 0000000..3e4742e --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/TestWebhookResponseDto.java @@ -0,0 +1,254 @@ +/** + * 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.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 = TestWebhookResponseDto.Builder.class) +public final class TestWebhookResponseDto { + private final boolean success; + + private final String message; + + private final Optional httpStatusCode; + + private final Optional responseBody; + + private final Map additionalProperties; + + private TestWebhookResponseDto( + boolean success, + String message, + Optional httpStatusCode, + Optional responseBody, + Map additionalProperties) { + this.success = success; + this.message = message; + this.httpStatusCode = httpStatusCode; + this.responseBody = responseBody; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the test delivery received a 2xx response; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return HTTP status code returned by the webhook endpoint. + */ + @JsonProperty("http_status_code") + public Optional getHttpStatusCode() { + return httpStatusCode; + } + + /** + * @return Response body returned by the webhook endpoint. Type varies by target. + */ + @JsonProperty("response_body") + public Optional getResponseBody() { + return responseBody; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TestWebhookResponseDto && equalTo((TestWebhookResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TestWebhookResponseDto other) { + return success == other.success + && message.equals(other.message) + && httpStatusCode.equals(other.httpStatusCode) + && responseBody.equals(other.responseBody); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.httpStatusCode, this.responseBody); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the test delivery received a 2xx response; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(TestWebhookResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

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

HTTP status code returned by the webhook endpoint.

+ */ + _FinalStage httpStatusCode(Optional httpStatusCode); + + _FinalStage httpStatusCode(Integer httpStatusCode); + + /** + *

Response body returned by the webhook endpoint. Type varies by target.

+ */ + _FinalStage responseBody(Optional responseBody); + + _FinalStage responseBody(Object responseBody); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + private Optional responseBody = Optional.empty(); + + private Optional httpStatusCode = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(TestWebhookResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + httpStatusCode(other.getHttpStatusCode()); + responseBody(other.getResponseBody()); + return this; + } + + /** + *

True if the test delivery received a 2xx response; false otherwise.

+ *

True if the test delivery received a 2xx response; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

Response body returned by the webhook endpoint. Type varies by target.

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

Response body returned by the webhook endpoint. Type varies by target.

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

HTTP status code returned by the webhook endpoint.

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

HTTP status code returned by the webhook endpoint.

+ */ + @java.lang.Override + @JsonSetter(value = "http_status_code", nulls = Nulls.SKIP) + public _FinalStage httpStatusCode(Optional httpStatusCode) { + this.httpStatusCode = httpStatusCode; + return this; + } + + @java.lang.Override + public TestWebhookResponseDto build() { + return new TestWebhookResponseDto(success, message, httpStatusCode, responseBody, 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/UpdateProjectResponseDto.java b/src/main/java/com/newscatcher/catchall/types/UpdateProjectResponseDto.java new file mode 100644 index 0000000..7f4c387 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/UpdateProjectResponseDto.java @@ -0,0 +1,196 @@ +/** + * 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.databind.annotation.JsonDeserialize; +import com.newscatcher.catchall.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateProjectResponseDto.Builder.class) +public final class UpdateProjectResponseDto { + private final boolean success; + + private final String message; + + private final String projectId; + + private final Map additionalProperties; + + private UpdateProjectResponseDto( + boolean success, String message, String projectId, Map additionalProperties) { + this.success = success; + this.message = message; + this.projectId = projectId; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the operation succeeded; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return Project identifier. + */ + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateProjectResponseDto && equalTo((UpdateProjectResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateProjectResponseDto other) { + return success == other.success && message.equals(other.message) && projectId.equals(other.projectId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.projectId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the operation succeeded; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(UpdateProjectResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

+ */ + ProjectIdStage message(@NotNull String message); + } + + public interface ProjectIdStage { + /** + *

Project identifier.

+ */ + _FinalStage projectId(@NotNull String projectId); + } + + public interface _FinalStage { + UpdateProjectResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, ProjectIdStage, _FinalStage { + private boolean success; + + private String message; + + private String projectId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateProjectResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + projectId(other.getProjectId()); + return this; + } + + /** + *

True if the operation succeeded; false otherwise.

+ *

True if the operation succeeded; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

Project identifier.

+ *

Project identifier.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("project_id") + public _FinalStage projectId(@NotNull String projectId) { + this.projectId = Objects.requireNonNull(projectId, "projectId must not be null"); + return this; + } + + @java.lang.Override + public UpdateProjectResponseDto build() { + return new UpdateProjectResponseDto(success, message, projectId, 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/UpdateWebhookResponseDto.java b/src/main/java/com/newscatcher/catchall/types/UpdateWebhookResponseDto.java new file mode 100644 index 0000000..b1f780d --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/UpdateWebhookResponseDto.java @@ -0,0 +1,209 @@ +/** + * 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.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 = UpdateWebhookResponseDto.Builder.class) +public final class UpdateWebhookResponseDto { + private final boolean success; + + private final String message; + + private final Optional webhook; + + private final Map additionalProperties; + + private UpdateWebhookResponseDto( + boolean success, + String message, + Optional webhook, + Map additionalProperties) { + this.success = success; + this.message = message; + this.webhook = webhook; + this.additionalProperties = additionalProperties; + } + + /** + * @return True if the webhook was updated; false otherwise. + */ + @JsonProperty("success") + public boolean getSuccess() { + return success; + } + + /** + * @return Human-readable result message. + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * @return The updated webhook object. + */ + @JsonProperty("webhook") + public Optional getWebhook() { + return webhook; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateWebhookResponseDto && equalTo((UpdateWebhookResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateWebhookResponseDto other) { + return success == other.success && message.equals(other.message) && webhook.equals(other.webhook); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.success, this.message, this.webhook); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SuccessStage builder() { + return new Builder(); + } + + public interface SuccessStage { + /** + *

True if the webhook was updated; false otherwise.

+ */ + MessageStage success(boolean success); + + Builder from(UpdateWebhookResponseDto other); + } + + public interface MessageStage { + /** + *

Human-readable result message.

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

The updated webhook object.

+ */ + _FinalStage webhook(Optional webhook); + + _FinalStage webhook(WebhookResponseDto webhook); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SuccessStage, MessageStage, _FinalStage { + private boolean success; + + private String message; + + private Optional webhook = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateWebhookResponseDto other) { + success(other.getSuccess()); + message(other.getMessage()); + webhook(other.getWebhook()); + return this; + } + + /** + *

True if the webhook was updated; false otherwise.

+ *

True if the webhook was updated; false otherwise.

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

Human-readable result message.

+ *

Human-readable result message.

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

The updated webhook object.

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

The updated webhook object.

+ */ + @java.lang.Override + @JsonSetter(value = "webhook", nulls = Nulls.SKIP) + public _FinalStage webhook(Optional webhook) { + this.webhook = webhook; + return this; + } + + @java.lang.Override + public UpdateWebhookResponseDto build() { + return new UpdateWebhookResponseDto(success, message, webhook, 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/ValidateQueryResponseDto.java b/src/main/java/com/newscatcher/catchall/types/ValidateQueryResponseDto.java new file mode 100644 index 0000000..10cb785 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/ValidateQueryResponseDto.java @@ -0,0 +1,334 @@ +/** + * 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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ValidateQueryResponseDto.Builder.class) +public final class ValidateQueryResponseDto { + private final QueryStatus status; + + private final String title; + + private final Optional description; + + private final Optional> issues; + + private final Optional> suggestions; + + private final double confidence; + + private final Map additionalProperties; + + private ValidateQueryResponseDto( + QueryStatus status, + String title, + Optional description, + Optional> issues, + Optional> suggestions, + double confidence, + Map additionalProperties) { + this.status = status; + this.title = title; + this.description = description; + this.issues = issues; + this.suggestions = suggestions; + this.confidence = confidence; + this.additionalProperties = additionalProperties; + } + + /** + * @return Overall quality level of the query. + */ + @JsonProperty("status") + public QueryStatus getStatus() { + return status; + } + + /** + * @return Short headline summarising the assessment. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return Plain-language explanation of the assessment result. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return Issues identified in the query. Empty when status is good. + */ + @JsonProperty("issues") + public Optional> getIssues() { + return issues; + } + + /** + * @return Actionable recommendations for each identified issue. Empty when status is good. Each suggestion corresponds to one entry in issues. + */ + @JsonProperty("suggestions") + public Optional> getSuggestions() { + return suggestions; + } + + /** + * @return Confidence score for this assessment. + */ + @JsonProperty("confidence") + public double getConfidence() { + return confidence; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ValidateQueryResponseDto && equalTo((ValidateQueryResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ValidateQueryResponseDto other) { + return status.equals(other.status) + && title.equals(other.title) + && description.equals(other.description) + && issues.equals(other.issues) + && suggestions.equals(other.suggestions) + && confidence == other.confidence; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.title, this.description, this.issues, this.suggestions, this.confidence); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static StatusStage builder() { + return new Builder(); + } + + public interface StatusStage { + /** + *

Overall quality level of the query.

+ */ + TitleStage status(@NotNull QueryStatus status); + + Builder from(ValidateQueryResponseDto other); + } + + public interface TitleStage { + /** + *

Short headline summarising the assessment.

+ */ + ConfidenceStage title(@NotNull String title); + } + + public interface ConfidenceStage { + /** + *

Confidence score for this assessment.

+ */ + _FinalStage confidence(double confidence); + } + + public interface _FinalStage { + ValidateQueryResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Plain-language explanation of the assessment result.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + /** + *

Issues identified in the query. Empty when status is good.

+ */ + _FinalStage issues(Optional> issues); + + _FinalStage issues(List issues); + + /** + *

Actionable recommendations for each identified issue. Empty when status is good. Each suggestion corresponds to one entry in issues.

+ */ + _FinalStage suggestions(Optional> suggestions); + + _FinalStage suggestions(List suggestions); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements StatusStage, TitleStage, ConfidenceStage, _FinalStage { + private QueryStatus status; + + private String title; + + private double confidence; + + private Optional> suggestions = Optional.empty(); + + private Optional> issues = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ValidateQueryResponseDto other) { + status(other.getStatus()); + title(other.getTitle()); + description(other.getDescription()); + issues(other.getIssues()); + suggestions(other.getSuggestions()); + confidence(other.getConfidence()); + return this; + } + + /** + *

Overall quality level of the query.

+ *

Overall quality level of the query.

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

Short headline summarising the assessment.

+ *

Short headline summarising the assessment.

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

Confidence score for this assessment.

+ *

Confidence score for this assessment.

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

Actionable recommendations for each identified issue. Empty when status is good. Each suggestion corresponds to one entry in issues.

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

Actionable recommendations for each identified issue. Empty when status is good. Each suggestion corresponds to one entry in issues.

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

Issues identified in the query. Empty when status is good.

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

Issues identified in the query. Empty when status is good.

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

Plain-language explanation of the assessment result.

+ * @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; + } + + /** + *

Plain-language explanation of the assessment result.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public ValidateQueryResponseDto build() { + return new ValidateQueryResponseDto( + status, title, description, issues, suggestions, confidence, 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/WebhookResourceMappingResponseDto.java b/src/main/java/com/newscatcher/catchall/types/WebhookResourceMappingResponseDto.java new file mode 100644 index 0000000..3f0d325 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/WebhookResourceMappingResponseDto.java @@ -0,0 +1,284 @@ +/** + * 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.time.OffsetDateTime; +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 = WebhookResourceMappingResponseDto.Builder.class) +public final class WebhookResourceMappingResponseDto { + private final String id; + + private final String webhookId; + + private final String resourceType; + + private final String resourceId; + + private final Optional assignedAt; + + private final Map additionalProperties; + + private WebhookResourceMappingResponseDto( + String id, + String webhookId, + String resourceType, + String resourceId, + Optional assignedAt, + Map additionalProperties) { + this.id = id; + this.webhookId = webhookId; + this.resourceType = resourceType; + this.resourceId = resourceId; + this.assignedAt = assignedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Mapping identifier. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Webhook identifier. + */ + @JsonProperty("webhook_id") + public String getWebhookId() { + return webhookId; + } + + /** + * @return Type of the assigned resource. + */ + @JsonProperty("resource_type") + public String getResourceType() { + return resourceType; + } + + /** + * @return Identifier of the assigned resource. + */ + @JsonProperty("resource_id") + public String getResourceId() { + return resourceId; + } + + /** + * @return Timestamp when the resource was assigned in ISO 8601 format with UTC timezone. + */ + @JsonProperty("assigned_at") + public Optional getAssignedAt() { + return assignedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof WebhookResourceMappingResponseDto && equalTo((WebhookResourceMappingResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(WebhookResourceMappingResponseDto other) { + return id.equals(other.id) + && webhookId.equals(other.webhookId) + && resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && assignedAt.equals(other.assignedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.webhookId, this.resourceType, this.resourceId, this.assignedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + *

Mapping identifier.

+ */ + WebhookIdStage id(@NotNull String id); + + Builder from(WebhookResourceMappingResponseDto other); + } + + public interface WebhookIdStage { + /** + *

Webhook identifier.

+ */ + ResourceTypeStage webhookId(@NotNull String webhookId); + } + + public interface ResourceTypeStage { + /** + *

Type of the assigned resource.

+ */ + ResourceIdStage resourceType(@NotNull String resourceType); + } + + public interface ResourceIdStage { + /** + *

Identifier of the assigned resource.

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

Timestamp when the resource was assigned in ISO 8601 format with UTC timezone.

+ */ + _FinalStage assignedAt(Optional assignedAt); + + _FinalStage assignedAt(OffsetDateTime assignedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, WebhookIdStage, ResourceTypeStage, ResourceIdStage, _FinalStage { + private String id; + + private String webhookId; + + private String resourceType; + + private String resourceId; + + private Optional assignedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(WebhookResourceMappingResponseDto other) { + id(other.getId()); + webhookId(other.getWebhookId()); + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + assignedAt(other.getAssignedAt()); + return this; + } + + /** + *

Mapping identifier.

+ *

Mapping identifier.

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

Webhook identifier.

+ *

Webhook identifier.

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

Type of the assigned resource.

+ *

Type of the assigned resource.

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

Identifier of the assigned resource.

+ *

Identifier of the assigned resource.

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

Timestamp when the resource was assigned in ISO 8601 format with UTC timezone.

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

Timestamp when the resource was assigned in ISO 8601 format with UTC timezone.

+ */ + @java.lang.Override + @JsonSetter(value = "assigned_at", nulls = Nulls.SKIP) + public _FinalStage assignedAt(Optional assignedAt) { + this.assignedAt = assignedAt; + return this; + } + + @java.lang.Override + public WebhookResourceMappingResponseDto build() { + return new WebhookResourceMappingResponseDto( + id, webhookId, resourceType, resourceId, assignedAt, 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/WebhookResponseDto.java b/src/main/java/com/newscatcher/catchall/types/WebhookResponseDto.java new file mode 100644 index 0000000..33ba350 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/WebhookResponseDto.java @@ -0,0 +1,679 @@ +/** + * 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.time.OffsetDateTime; +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 = WebhookResponseDto.Builder.class) +public final class WebhookResponseDto { + private final String id; + + private final String name; + + private final String url; + + private final WebhookType type; + + private final DeliveryMode deliveryMode; + + private final HttpMethod method; + + private final Optional> headers; + + private final Optional> params; + + private final Optional> formatterConfig; + + private final boolean isActive; + + private final Optional organizationId; + + private final Optional createdByUserId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private WebhookResponseDto( + String id, + String name, + String url, + WebhookType type, + DeliveryMode deliveryMode, + HttpMethod method, + Optional> headers, + Optional> params, + Optional> formatterConfig, + boolean isActive, + Optional organizationId, + Optional createdByUserId, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.name = name; + this.url = url; + this.type = type; + this.deliveryMode = deliveryMode; + this.method = method; + this.headers = headers; + this.params = params; + this.formatterConfig = formatterConfig; + this.isActive = isActive; + this.organizationId = organizationId; + this.createdByUserId = createdByUserId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Webhook identifier. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return Human-readable label for this webhook. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Destination URL that receives the payload. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @JsonProperty("type") + public WebhookType getType() { + return type; + } + + @JsonProperty("delivery_mode") + public DeliveryMode getDeliveryMode() { + return deliveryMode; + } + + @JsonProperty("method") + public HttpMethod getMethod() { + return method; + } + + /** + * @return Custom HTTP headers forwarded with each delivery. + */ + @JsonProperty("headers") + public Optional> getHeaders() { + return headers; + } + + /** + * @return Query parameters appended to the webhook URL. + */ + @JsonProperty("params") + public Optional> getParams() { + return params; + } + + /** + * @return Custom payload transformation configuration. Used only when type is custom. + */ + @JsonIgnore + public Optional> getFormatterConfig() { + if (formatterConfig == null) { + return Optional.empty(); + } + return formatterConfig; + } + + /** + * @return True if the webhook is active; false otherwise. + */ + @JsonProperty("is_active") + public boolean getIsActive() { + return isActive; + } + + /** + * @return Organization that owns this webhook. + */ + @JsonProperty("organization_id") + public Optional getOrganizationId() { + return organizationId; + } + + /** + * @return ID of the user who created this webhook. + */ + @JsonProperty("created_by_user_id") + public Optional getCreatedByUserId() { + return createdByUserId; + } + + /** + * @return Webhook creation timestamp in ISO 8601 format with UTC timezone. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp of the last update in ISO 8601 format with UTC timezone. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("formatter_config") + private Optional> _getFormatterConfig() { + return formatterConfig; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof WebhookResponseDto && equalTo((WebhookResponseDto) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(WebhookResponseDto other) { + return id.equals(other.id) + && name.equals(other.name) + && url.equals(other.url) + && type.equals(other.type) + && deliveryMode.equals(other.deliveryMode) + && method.equals(other.method) + && headers.equals(other.headers) + && params.equals(other.params) + && formatterConfig.equals(other.formatterConfig) + && isActive == other.isActive + && organizationId.equals(other.organizationId) + && createdByUserId.equals(other.createdByUserId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.url, + this.type, + this.deliveryMode, + this.method, + this.headers, + this.params, + this.formatterConfig, + this.isActive, + this.organizationId, + this.createdByUserId, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + *

Webhook identifier.

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

Human-readable label for this webhook.

+ */ + UrlStage name(@NotNull String name); + } + + public interface UrlStage { + /** + *

Destination URL that receives the payload.

+ */ + TypeStage url(@NotNull String url); + } + + public interface TypeStage { + DeliveryModeStage type(@NotNull WebhookType type); + } + + public interface DeliveryModeStage { + MethodStage deliveryMode(@NotNull DeliveryMode deliveryMode); + } + + public interface MethodStage { + IsActiveStage method(@NotNull HttpMethod method); + } + + public interface IsActiveStage { + /** + *

True if the webhook is active; false otherwise.

+ */ + _FinalStage isActive(boolean isActive); + } + + public interface _FinalStage { + WebhookResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Custom HTTP headers forwarded with each delivery.

+ */ + _FinalStage headers(Optional> headers); + + _FinalStage headers(Map headers); + + /** + *

Query parameters appended to the webhook URL.

+ */ + _FinalStage params(Optional> params); + + _FinalStage params(Map params); + + /** + *

Custom payload transformation configuration. Used only when type is custom.

+ */ + _FinalStage formatterConfig(Optional> formatterConfig); + + _FinalStage formatterConfig(Map formatterConfig); + + _FinalStage formatterConfig(Nullable> formatterConfig); + + /** + *

Organization that owns this webhook.

+ */ + _FinalStage organizationId(Optional organizationId); + + _FinalStage organizationId(String organizationId); + + /** + *

ID of the user who created this webhook.

+ */ + _FinalStage createdByUserId(Optional createdByUserId); + + _FinalStage createdByUserId(String createdByUserId); + + /** + *

Webhook creation timestamp in ISO 8601 format with UTC timezone.

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

Timestamp of the last update in ISO 8601 format with UTC timezone.

+ */ + _FinalStage updatedAt(Optional updatedAt); + + _FinalStage updatedAt(OffsetDateTime updatedAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + NameStage, + UrlStage, + TypeStage, + DeliveryModeStage, + MethodStage, + IsActiveStage, + _FinalStage { + private String id; + + private String name; + + private String url; + + private WebhookType type; + + private DeliveryMode deliveryMode; + + private HttpMethod method; + + private boolean isActive; + + private Optional updatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional createdByUserId = Optional.empty(); + + private Optional organizationId = Optional.empty(); + + private Optional> formatterConfig = Optional.empty(); + + private Optional> params = Optional.empty(); + + private Optional> headers = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(WebhookResponseDto other) { + id(other.getId()); + name(other.getName()); + url(other.getUrl()); + type(other.getType()); + deliveryMode(other.getDeliveryMode()); + method(other.getMethod()); + headers(other.getHeaders()); + params(other.getParams()); + formatterConfig(other.getFormatterConfig()); + isActive(other.getIsActive()); + organizationId(other.getOrganizationId()); + createdByUserId(other.getCreatedByUserId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

Webhook identifier.

+ *

Webhook identifier.

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

Human-readable label for this webhook.

+ *

Human-readable label for this webhook.

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

Destination URL that receives the payload.

+ *

Destination URL that receives the payload.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public TypeStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("type") + public DeliveryModeStage type(@NotNull WebhookType type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("delivery_mode") + public MethodStage deliveryMode(@NotNull DeliveryMode deliveryMode) { + this.deliveryMode = Objects.requireNonNull(deliveryMode, "deliveryMode must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("method") + public IsActiveStage method(@NotNull HttpMethod method) { + this.method = Objects.requireNonNull(method, "method must not be null"); + return this; + } + + /** + *

True if the webhook is active; false otherwise.

+ *

True if the webhook is active; false otherwise.

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

Timestamp of the last update in ISO 8601 format with UTC timezone.

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

Timestamp of the last update in ISO 8601 format with UTC timezone.

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

Webhook creation timestamp in ISO 8601 format with UTC timezone.

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

Webhook creation timestamp in ISO 8601 format with UTC timezone.

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

ID of the user who created this webhook.

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

ID of the user who created this webhook.

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

Organization that owns this webhook.

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

Organization that owns this webhook.

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

Custom payload transformation configuration. Used only when type is custom.

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

Custom payload transformation configuration. Used only when type is custom.

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

Custom payload transformation configuration. Used only when type is custom.

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

Query parameters appended to the webhook URL.

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

Query parameters appended to the webhook URL.

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

Custom HTTP headers forwarded with each delivery.

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

Custom HTTP headers forwarded with each delivery.

+ */ + @java.lang.Override + @JsonSetter(value = "headers", nulls = Nulls.SKIP) + public _FinalStage headers(Optional> headers) { + this.headers = headers; + return this; + } + + @java.lang.Override + public WebhookResponseDto build() { + return new WebhookResponseDto( + id, + name, + url, + type, + deliveryMode, + method, + headers, + params, + formatterConfig, + isActive, + organizationId, + createdByUserId, + createdAt, + updatedAt, + 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/WebhookType.java b/src/main/java/com/newscatcher/catchall/types/WebhookType.java new file mode 100644 index 0000000..0c94a71 --- /dev/null +++ b/src/main/java/com/newscatcher/catchall/types/WebhookType.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.catchall.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class WebhookType { + public static final WebhookType TEAMS = new WebhookType(Value.TEAMS, "teams"); + + public static final WebhookType CUSTOM = new WebhookType(Value.CUSTOM, "custom"); + + public static final WebhookType GENERIC = new WebhookType(Value.GENERIC, "generic"); + + public static final WebhookType SLACK = new WebhookType(Value.SLACK, "slack"); + + private final Value value; + + private final String string; + + WebhookType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof WebhookType && this.string.equals(((WebhookType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case TEAMS: + return visitor.visitTeams(); + case CUSTOM: + return visitor.visitCustom(); + case GENERIC: + return visitor.visitGeneric(); + case SLACK: + return visitor.visitSlack(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static WebhookType valueOf(String value) { + switch (value) { + case "teams": + return TEAMS; + case "custom": + return CUSTOM; + case "generic": + return GENERIC; + case "slack": + return SLACK; + default: + return new WebhookType(Value.UNKNOWN, value); + } + } + + public enum Value { + GENERIC, + + SLACK, + + TEAMS, + + CUSTOM, + + UNKNOWN + } + + public interface Visitor { + T visitGeneric(); + + T visitSlack(); + + T visitTeams(); + + T visitCustom(); + + T visitUnknown(String unknownType); + } +}