diff --git a/.fern/metadata.json b/.fern/metadata.json
index a960126..08dbb3c 100644
--- a/.fern/metadata.json
+++ b/.fern/metadata.json
@@ -10,9 +10,9 @@
"base-exception-class-name": "CloudPDFException",
"base-api-exception-class-name": "CloudPDFApiException"
},
- "originGitCommit": "c6f87eecf9636e7ef367946a7fd7f3729401ce90",
+ "originGitCommit": "7ded7de29f4cc0dc9da18042fca6afd5c9557bfc",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
- "requestedVersion": "3.0.0-alpha.15",
+ "requestedVersion": "3.0.0-alpha.16",
"ciProvider": "github"
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index bc86627..24ad33d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,7 +46,7 @@ java {
group = 'com.cloudpdf'
-version = '3.0.0-alpha.15'
+version = '3.0.0-alpha.16'
jar {
dependsOn(":generatePomFileForMavenPublication")
@@ -73,7 +73,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cloudpdf'
artifactId = 'sdk'
- version = '3.0.0-alpha.15'
+ version = '3.0.0-alpha.16'
from components.java
pom {
name = 'CloudPDF'
diff --git a/cloudpdf-generation.json b/cloudpdf-generation.json
index f11139e..1c1092b 100644
--- a/cloudpdf-generation.json
+++ b/cloudpdf-generation.json
@@ -1,12 +1,12 @@
{
"language": "java",
- "canonicalVersion": "3.0.0-next.15",
- "sdkVersion": "3.0.0-alpha.15",
+ "canonicalVersion": "3.0.0-next.16",
+ "sdkVersion": "3.0.0-alpha.16",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
- "openapiSha256": "9d70deca638cc7a80b0e670ec47fc45710d6603eb8f493d5fac95a38d7e5f8b3",
- "gitCommit": "c6f87eecf9636e7ef367946a7fd7f3729401ce90",
+ "openapiSha256": "06543c26918bd79d426bf242c5a3091cdb7d298d3ac3296addabee2be80edb15",
+ "gitCommit": "7ded7de29f4cc0dc9da18042fca6afd5c9557bfc",
"gitCommitIsDirty": false
},
"fern": {
diff --git a/reference.md b/reference.md
index 93e53a8..3f68c26 100644
--- a/reference.md
+++ b/reference.md
@@ -91,7 +91,7 @@ client.doc().head(
-
-Each change stands on its own and names itself by `opId`: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its `opId`, a change gets the same answer, refusals included; a different change under an answered `opId` is refused (IdempotencyKeyReused). `{ opId, undoOf }` undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need `doc.annotate.modify`, form values `doc.forms.fill`, form structure `doc.forms.modify`, metadata `doc.metadata.modify`. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON `body` part, each op naming its files by role as `resources: { : '' }`, and each file as the part `resource:`. At most 64 changes per request and 512 ops per change.
+Each change stands on its own and names itself by `opId`: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its `opId`, a change gets the same answer, refusals included; a different change under an answered `opId` is refused (IdempotencyKeyReused). `{ opId, undoOf }` undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need `doc.annotate.modify`, form values `doc.forms.fill`, form structure `doc.forms.modify`, metadata `doc.metadata.modify`, outline `doc.outline.modify`, pages `doc.pages.assemble`, embedded files `doc.attachments.modify`. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON `body` part, each op naming its files by role as `resources: { : '' }`, and each file as the part `resource:`. At most 64 changes per request and 512 ops per change.
@@ -2642,6 +2642,100 @@ client.doc().annotations().readAppearance(
+
+
+
+
+client.doc.annotations.readFile(docId, layerName, pageKey, annotKey) -> InputStream
+
+-
+
+#### 📝 Description
+
+
+-
+
+
+-
+
+A file that decodes past the server's limit is refused (PayloadTooLarge).
+
+
+
+
+
+#### 🔌 Usage
+
+
+-
+
+
+-
+
+```java
+client.doc().annotations().readFile(
+ "docId",
+ "layerName",
+ "pageKey",
+ "annotKey",
+ ReadFileAnnotationsRequest
+ .builder()
+ .build()
+);
+```
+
+
+
+
+
+#### ⚙️ Parameters
+
+
+-
+
+
+-
+
+**docId:** `String`
+
+
+
+
+
+-
+
+**layerName:** `String`
+
+
+
+
+
+-
+
+**pageKey:** `String` — The page's address, `obj:N`: the page's indirect object number, the durable identity every `PageLayout.ref` carries. Mirrors `annotKey` and `fieldKey`.
+
+
+
+
+
+-
+
+**annotKey:** `String` — The annotation's address on the page: `obj:N`, its indirect object number, or `base:N` for an annotation the uploaded file stored inline (without an object number of its own), the position it was born at in the page's /Annots. The name the annotation's `ref` carries for life.
+
+
+
+
+
+-
+
+**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+
+
+
+
+
+
+
@@ -2935,6 +3029,168 @@ client.doc().annotations().reorder(
+
+
+
+
+## Doc Attachments
+client.doc.attachments.download(docId, layerName, fileKey) -> InputStream
+
+-
+
+#### 📝 Description
+
+
+-
+
+
+-
+
+A file that decodes past the server's limit is refused (PayloadTooLarge).
+
+
+
+
+
+#### 🔌 Usage
+
+
+-
+
+
+-
+
+```java
+client.doc().attachments().download(
+ "docId",
+ "layerName",
+ "fileKey",
+ DownloadAttachmentsRequest
+ .builder()
+ .build()
+);
+```
+
+
+
+
+
+#### ⚙️ Parameters
+
+
+-
+
+
+-
+
+**docId:** `String`
+
+
+
+
+
+-
+
+**layerName:** `String`
+
+
+
+
+
+-
+
+**fileKey:** `String` — The embedded file's name-tree key (its `ref.key`), token-text encoded, as `fieldKey` is.
+
+
+
+
+
+-
+
+**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+
+
+
+
+
+
+
+
+
+
+
+client.doc.attachments.list(docId, layerName) -> AttachmentList
+
+-
+
+#### 📝 Description
+
+
+-
+
+
+-
+
+A file-attachment annotation's file is listed with the annotation; read its bytes with `doc.annotations.readFile`.
+
+
+
+
+
+#### 🔌 Usage
+
+
+-
+
+
+-
+
+```java
+client.doc().attachments().list(
+ "docId",
+ "layerName",
+ ListAttachmentsRequest
+ .builder()
+ .build()
+);
+```
+
+
+
+
+
+#### ⚙️ Parameters
+
+
+-
+
+
+-
+
+**docId:** `String`
+
+
+
+
+
+-
+
+**layerName:** `String`
+
+
+
+
+
+-
+
+**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+
+
+
+
+
+
+
@@ -3638,8 +3894,8 @@ client.doc().metadata().get(
-## Doc Pages
-client.doc.pages.setScale(docId, layerName, pageKey, request) -> DocPagesSetScale200Response
+## Doc Outline
+client.doc.outline.get(docId, layerName) -> DocumentOutline
-
@@ -3652,11 +3908,10 @@ client.doc().metadata().get(
-
```java
-client.doc().pages().setScale(
+client.doc().outline().get(
"docId",
"layerName",
- "pageKey",
- DocPagesSetScaleRequest
+ GetOutlineRequest
.builder()
.build()
);
@@ -3690,43 +3945,20 @@ client.doc().pages().setScale(
-
-**pageKey:** `String` — The page's address, `obj:N`: the page's indirect object number, the durable identity every `PageLayout.ref` carries. Mirrors `annotKey` and `fieldKey`.
+**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+
+
-
--
-**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
+
-
--
-
-**idempotencyKey:** `Optional` — Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
-
-
-
-
-
--
-
-**measure:** `Optional`
-
-
-
-
-
-
-
-
-
-
-
-client.doc.pages.viewports(docId, layerName, pageKey) -> DocPagesViewports200Response
+## Doc Pages
+client.doc.pages.setScale(docId, layerName, pageKey, request) -> DocPagesSetScale200Response
-
@@ -3739,11 +3971,11 @@ client.doc().pages().setScale(
-
```java
-client.doc().pages().viewports(
+client.doc().pages().setScale(
"docId",
"layerName",
"pageKey",
- ViewportsPagesRequest
+ DocPagesSetScaleRequest
.builder()
.build()
);
@@ -3787,73 +4019,6 @@ client.doc().pages().viewports(
**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
-
-
-
-
-
-
-
-
-
-client.doc.pages.delete(docId, layerName, request) -> DocPagesDelete200Response
-
--
-
-#### 🔌 Usage
-
-
--
-
-
--
-
-```java
-client.doc().pages().delete(
- "docId",
- "layerName",
- DeletePagesRequest
- .builder()
- .body(
- new HashMap() {{
- put("key", "value");
- }}
- )
- .build()
-);
-```
-
-
-
-
-
-#### ⚙️ Parameters
-
-
--
-
-
--
-
-**docId:** `String`
-
-
-
-
-
--
-
-**layerName:** `String`
-
-
-
-
-
--
-
-**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
@@ -3868,7 +4033,7 @@ client.doc().pages().delete(
-
-**request:** `Map`
+**measure:** `Optional`
@@ -3880,24 +4045,10 @@ client.doc().pages().delete(
-client.doc.pages.extract(docId, layerName, request) -> InputStream
-
--
-
-#### 📝 Description
-
-
--
-
+
client.doc.pages.viewports(docId, layerName, pageKey) -> DocPagesViewports200Response
-
-A read, not a mutation: the source document is untouched and no event is published. Body is `{"pages": PageRef[]}`; the response body is the new PDF.
-
-
-
-
-
#### 🔌 Usage
@@ -3907,18 +4058,12 @@ A read, not a mutation: the source document is untouched and no event is publish
-
```java
-client.doc().pages().extract(
+client.doc().pages().viewports(
"docId",
"layerName",
- ExtractPagesRequest
+ "pageKey",
+ ViewportsPagesRequest
.builder()
- .body(
- new HashMap() {{
- put("string", new
- HashMap() {{put("key", "value");
- }});
- }}
- )
.build()
);
```
@@ -3951,74 +4096,7 @@ client.doc().pages().extract(
-
-**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
-
-
-
-
--
-
-**request:** `Map`
-
-
-
-
-
-
-
-
-
-
-
-client.doc.pages.flatten(docId, layerName, request) -> DocPagesFlatten200Response
-
--
-
-#### 🔌 Usage
-
-
--
-
-
--
-
-```java
-client.doc().pages().flatten(
- "docId",
- "layerName",
- FlattenPagesRequest
- .builder()
- .body(
- new HashMap() {{
- put("key", "value");
- }}
- )
- .build()
-);
-```
-
-
-
-
-
-#### ⚙️ Parameters
-
-
--
-
-
--
-
-**docId:** `String`
-
-
-
-
-
--
-
-**layerName:** `String`
+**pageKey:** `String` — The page's address, `obj:N`: the page's indirect object number, the durable identity every `PageLayout.ref` carries. Mirrors `annotKey` and `fieldKey`.
@@ -4028,22 +4106,6 @@ client.doc().pages().flatten(
**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
-
-
-
--
-
-**idempotencyKey:** `Optional` — Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
-
-
-
-
-
--
-
-**request:** `Map`
-
@@ -4054,7 +4116,7 @@ client.doc().pages().flatten(
-client.doc.pages.insert(docId, layerName, request) -> DocPagesInsert200Response
+client.doc.pages.extract(docId, layerName, request) -> InputStream
-
@@ -4066,7 +4128,7 @@ client.doc().pages().flatten(
-
-Multipart: a JSON `body` part `{"position"?: PagePosition, "resources": {"source": ""}}` (position omitted → the end), and the standalone PDF whose pages are copied in as the part `resource:`. The inserted copies get fresh page object numbers, returned in insertion order.
+A read, not a mutation: the source document is untouched and no event is published. Body is `{"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}`; the response body is the new PDF. With `flatten` the copy is the pages as they draw for `usage` (`"print"`: a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes `doc.download` or `doc.download.flattened`, and paints only what the caller may read; `includeAnnotations` and `includeFormFields` choose what it paints, and are refused without `flatten`.
@@ -4081,12 +4143,18 @@ Multipart: a JSON `body` part `{"position"?: PagePosition, "resources": {"source
-
```java
-client.doc().pages().insert(
+client.doc().pages().extract(
"docId",
"layerName",
- null,
- InsertPagesRequest
+ ExtractPagesRequest
.builder()
+ .body(
+ new HashMap() {{
+ put("string", new
+ HashMap() {{put("key", "value");
+ }});
+ }}
+ )
.build()
);
```
@@ -4127,7 +4195,7 @@ client.doc().pages().insert(
-
-**idempotencyKey:** `Optional` — Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
+**request:** `Map`
@@ -4139,24 +4207,10 @@ client.doc().pages().insert(
-client.doc.pages.insertBlank(docId, layerName, request) -> DocPagesInsertBlank200Response
-
--
-
-#### 📝 Description
-
-
--
-
+
client.doc.pages.flatten(docId, layerName, request) -> DocPagesFlatten200Response
-
-Body is `{"size": {"width", "height"}, "count"?, "position"?}` — size in PDF points, count in [1, 100], `position` a `PagePosition` (omitted → the end).
-
-
-
-
-
#### 🔌 Usage
@@ -4166,10 +4220,10 @@ Body is `{"size": {"width", "height"}, "count"?, "position"?}` — size in PDF p
-
```java
-client.doc().pages().insertBlank(
+client.doc().pages().flatten(
"docId",
"layerName",
- InsertBlankPagesRequest
+ FlattenPagesRequest
.builder()
.body(
new HashMap() {{
@@ -4398,187 +4452,6 @@ client.doc().pages().removeName(
-
-
-
-
-client.doc.pages.reorder(docId, layerName, request) -> DocPagesReorder200Response
-
--
-
-#### 🔌 Usage
-
-
--
-
-
--
-
-```java
-client.doc().pages().reorder(
- "docId",
- "layerName",
- DocPagesReorderRequest
- .builder()
- .position(
- PagePosition.of(PagePositionZero.START)
- )
- .pages(
- Arrays.asList(
- PageRef
- .builder()
- .kind(PageRefKind.OBJECT_NUMBER)
- .objectNumber(1)
- .build()
- )
- )
- .build()
-);
-```
-
-
-
-
-
-#### ⚙️ Parameters
-
-
--
-
-
--
-
-**docId:** `String`
-
-
-
-
-
--
-
-**layerName:** `String`
-
-
-
-
-
--
-
-**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
-
-
-
-
--
-
-**idempotencyKey:** `Optional` — Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
-
-
-
-
-
--
-
-**pages:** `List`
-
-
-
-
-
--
-
-**position:** `PagePosition`
-
-
-
-
-
-
-
-
-
-
-
-client.doc.pages.rotate(docId, layerName, request) -> DocPagesRotate200Response
-
--
-
-#### 🔌 Usage
-
-
--
-
-
--
-
-```java
-client.doc().pages().rotate(
- "docId",
- "layerName",
- RotatePagesRequest
- .builder()
- .body(
- new HashMap() {{
- put("key", "value");
- }}
- )
- .build()
-);
-```
-
-
-
-
-
-#### ⚙️ Parameters
-
-
--
-
-
--
-
-**docId:** `String`
-
-
-
-
-
--
-
-**layerName:** `String`
-
-
-
-
-
--
-
-**documentPassword:** `Optional` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
-
-
-
-
-
--
-
-**idempotencyKey:** `Optional` — Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
-
-
-
-
-
--
-
-**request:** `Map`
-
-
-
-
-
-
-
diff --git a/src/main/java/api/core/ClientOptions.java b/src/main/java/api/core/ClientOptions.java
index b7ecfe6..31e9533 100644
--- a/src/main/java/api/core/ClientOptions.java
+++ b/src/main/java/api/core/ClientOptions.java
@@ -49,7 +49,7 @@ private ClientOptions(
{
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.cloudpdf:sdk");
- put("X-Fern-SDK-Version", "3.0.0-alpha.15");
+ put("X-Fern-SDK-Version", "3.0.0-alpha.16");
}
});
this.headerSuppliers = headerSuppliers;
diff --git a/src/main/java/api/errors/ContentTooLargeError.java b/src/main/java/api/errors/ContentTooLargeError.java
index bd30678..a3f6811 100644
--- a/src/main/java/api/errors/ContentTooLargeError.java
+++ b/src/main/java/api/errors/ContentTooLargeError.java
@@ -4,21 +4,20 @@
package com.cloudpdf.api.errors;
import com.cloudpdf.api.core.CloudPDFApiException;
-import com.cloudpdf.api.types.EngineErrorPayload;
import okhttp3.Response;
public final class ContentTooLargeError extends CloudPDFApiException {
/**
* The body of the response that triggered the exception.
*/
- private final EngineErrorPayload body;
+ private final Object body;
- public ContentTooLargeError(EngineErrorPayload body) {
+ public ContentTooLargeError(Object body) {
super("ContentTooLargeError", 413, body);
this.body = body;
}
- public ContentTooLargeError(EngineErrorPayload body, Response rawResponse) {
+ public ContentTooLargeError(Object body, Response rawResponse) {
super("ContentTooLargeError", 413, body, rawResponse);
this.body = body;
}
@@ -27,7 +26,7 @@ public ContentTooLargeError(EngineErrorPayload body, Response rawResponse) {
* @return the body
*/
@java.lang.Override
- public EngineErrorPayload body() {
+ public Object body() {
return this.body;
}
}
diff --git a/src/main/java/api/resources/doc/AsyncDocClient.java b/src/main/java/api/resources/doc/AsyncDocClient.java
index a1dca82..8a3f8a6 100644
--- a/src/main/java/api/resources/doc/AsyncDocClient.java
+++ b/src/main/java/api/resources/doc/AsyncDocClient.java
@@ -7,8 +7,10 @@
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.api.core.Suppliers;
import com.cloudpdf.api.resources.doc.annotations.AsyncAnnotationsClient;
+import com.cloudpdf.api.resources.doc.attachments.AsyncAttachmentsClient;
import com.cloudpdf.api.resources.doc.forms.AsyncFormsClient;
import com.cloudpdf.api.resources.doc.metadata.AsyncMetadataClient;
+import com.cloudpdf.api.resources.doc.outline.AsyncOutlineClient;
import com.cloudpdf.api.resources.doc.pages.AsyncPagesClient;
import com.cloudpdf.api.resources.doc.redactions.AsyncRedactionsClient;
import com.cloudpdf.api.resources.doc.requests.DocChangesRequest;
@@ -34,10 +36,14 @@ public class AsyncDocClient {
protected final Supplier annotationsClient;
+ protected final Supplier attachmentsClient;
+
protected final Supplier formsClient;
protected final Supplier metadataClient;
+ protected final Supplier outlineClient;
+
protected final Supplier pagesClient;
protected final Supplier redactionsClient;
@@ -50,8 +56,10 @@ public AsyncDocClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new AsyncRawDocClient(clientOptions);
this.annotationsClient = Suppliers.memoize(() -> new AsyncAnnotationsClient(clientOptions));
+ this.attachmentsClient = Suppliers.memoize(() -> new AsyncAttachmentsClient(clientOptions));
this.formsClient = Suppliers.memoize(() -> new AsyncFormsClient(clientOptions));
this.metadataClient = Suppliers.memoize(() -> new AsyncMetadataClient(clientOptions));
+ this.outlineClient = Suppliers.memoize(() -> new AsyncOutlineClient(clientOptions));
this.pagesClient = Suppliers.memoize(() -> new AsyncPagesClient(clientOptions));
this.redactionsClient = Suppliers.memoize(() -> new AsyncRedactionsClient(clientOptions));
this.signaturesClient = Suppliers.memoize(() -> new AsyncSignaturesClient(clientOptions));
@@ -83,14 +91,14 @@ public CompletableFuture head(
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CompletableFuture changes(String docId, String layerName, DocChangesRequest request) {
return this.rawClient.changes(docId, layerName, request).thenApply(response -> response.body());
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CompletableFuture changes(
String docId, String layerName, DocChangesRequest request, RequestOptions requestOptions) {
@@ -195,6 +203,10 @@ public AsyncAnnotationsClient annotations() {
return this.annotationsClient.get();
}
+ public AsyncAttachmentsClient attachments() {
+ return this.attachmentsClient.get();
+ }
+
public AsyncFormsClient forms() {
return this.formsClient.get();
}
@@ -203,6 +215,10 @@ public AsyncMetadataClient metadata() {
return this.metadataClient.get();
}
+ public AsyncOutlineClient outline() {
+ return this.outlineClient.get();
+ }
+
public AsyncPagesClient pages() {
return this.pagesClient.get();
}
diff --git a/src/main/java/api/resources/doc/AsyncRawDocClient.java b/src/main/java/api/resources/doc/AsyncRawDocClient.java
index 12a76d5..35ff242 100644
--- a/src/main/java/api/resources/doc/AsyncRawDocClient.java
+++ b/src/main/java/api/resources/doc/AsyncRawDocClient.java
@@ -26,7 +26,6 @@
import com.cloudpdf.api.types.DocHead200Response;
import com.cloudpdf.api.types.DocManifest200Response;
import com.cloudpdf.api.types.DocText200Response;
-import com.cloudpdf.api.types.EngineErrorPayload;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.io.InputStream;
@@ -140,7 +139,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CompletableFuture> changes(
String docId, String layerName, DocChangesRequest request) {
@@ -148,7 +147,7 @@ public CompletableFuture> chan
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CompletableFuture> changes(
String docId, String layerName, DocChangesRequest request, RequestOptions requestOptions) {
@@ -226,8 +225,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
return;
case 413:
future.completeExceptionally(new ContentTooLargeError(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, EngineErrorPayload.class),
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
}
diff --git a/src/main/java/api/resources/doc/DocClient.java b/src/main/java/api/resources/doc/DocClient.java
index 5ddfe52..b0b9a2f 100644
--- a/src/main/java/api/resources/doc/DocClient.java
+++ b/src/main/java/api/resources/doc/DocClient.java
@@ -7,8 +7,10 @@
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.api.core.Suppliers;
import com.cloudpdf.api.resources.doc.annotations.AnnotationsClient;
+import com.cloudpdf.api.resources.doc.attachments.AttachmentsClient;
import com.cloudpdf.api.resources.doc.forms.FormsClient;
import com.cloudpdf.api.resources.doc.metadata.MetadataClient;
+import com.cloudpdf.api.resources.doc.outline.OutlineClient;
import com.cloudpdf.api.resources.doc.pages.PagesClient;
import com.cloudpdf.api.resources.doc.redactions.RedactionsClient;
import com.cloudpdf.api.resources.doc.requests.DocChangesRequest;
@@ -33,10 +35,14 @@ public class DocClient {
protected final Supplier annotationsClient;
+ protected final Supplier attachmentsClient;
+
protected final Supplier formsClient;
protected final Supplier metadataClient;
+ protected final Supplier outlineClient;
+
protected final Supplier pagesClient;
protected final Supplier redactionsClient;
@@ -49,8 +55,10 @@ public DocClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.rawClient = new RawDocClient(clientOptions);
this.annotationsClient = Suppliers.memoize(() -> new AnnotationsClient(clientOptions));
+ this.attachmentsClient = Suppliers.memoize(() -> new AttachmentsClient(clientOptions));
this.formsClient = Suppliers.memoize(() -> new FormsClient(clientOptions));
this.metadataClient = Suppliers.memoize(() -> new MetadataClient(clientOptions));
+ this.outlineClient = Suppliers.memoize(() -> new OutlineClient(clientOptions));
this.pagesClient = Suppliers.memoize(() -> new PagesClient(clientOptions));
this.redactionsClient = Suppliers.memoize(() -> new RedactionsClient(clientOptions));
this.signaturesClient = Suppliers.memoize(() -> new SignaturesClient(clientOptions));
@@ -81,14 +89,14 @@ public DocHead200Response head(String docId, HeadDocRequest request, RequestOpti
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public DocChanges200Response changes(String docId, String layerName, DocChangesRequest request) {
return this.rawClient.changes(docId, layerName, request).body();
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public DocChanges200Response changes(
String docId, String layerName, DocChangesRequest request, RequestOptions requestOptions) {
@@ -187,6 +195,10 @@ public AnnotationsClient annotations() {
return this.annotationsClient.get();
}
+ public AttachmentsClient attachments() {
+ return this.attachmentsClient.get();
+ }
+
public FormsClient forms() {
return this.formsClient.get();
}
@@ -195,6 +207,10 @@ public MetadataClient metadata() {
return this.metadataClient.get();
}
+ public OutlineClient outline() {
+ return this.outlineClient.get();
+ }
+
public PagesClient pages() {
return this.pagesClient.get();
}
diff --git a/src/main/java/api/resources/doc/RawDocClient.java b/src/main/java/api/resources/doc/RawDocClient.java
index 121fff5..3ef810e 100644
--- a/src/main/java/api/resources/doc/RawDocClient.java
+++ b/src/main/java/api/resources/doc/RawDocClient.java
@@ -26,7 +26,6 @@
import com.cloudpdf.api.types.DocHead200Response;
import com.cloudpdf.api.types.DocManifest200Response;
import com.cloudpdf.api.types.DocText200Response;
-import com.cloudpdf.api.types.EngineErrorPayload;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.io.InputStream;
@@ -118,7 +117,7 @@ public CloudPDFClientHttpResponse head(
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CloudPDFClientHttpResponse changes(
String docId, String layerName, DocChangesRequest request) {
@@ -126,7 +125,7 @@ public CloudPDFClientHttpResponse changes(
}
/**
- * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
+ * Each change stands on its own and names itself by opId: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its opId, a change gets the same answer, refusals included; a different change under an answered opId is refused (IdempotencyKeyReused). { opId, undoOf } undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need doc.annotate.modify, form values doc.forms.fill, form structure doc.forms.modify, metadata doc.metadata.modify, outline doc.outline.modify, pages doc.pages.assemble, embedded files doc.attachments.modify. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) travel as multipart: a JSON body part, each op naming its files by role as resources: { <role>: '<key>' }, and each file as the part resource:<key>. At most 64 changes per request and 512 ops per change.
*/
public CloudPDFClientHttpResponse changes(
String docId, String layerName, DocChangesRequest request, RequestOptions requestOptions) {
@@ -193,8 +192,7 @@ public CloudPDFClientHttpResponse changes(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
case 413:
throw new ContentTooLargeError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, EngineErrorPayload.class),
- response);
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
}
} catch (JsonProcessingException ignored) {
// unable to map error response, throwing generic error
diff --git a/src/main/java/api/resources/doc/annotations/AnnotationsClient.java b/src/main/java/api/resources/doc/annotations/AnnotationsClient.java
index dfc3d28..3ba5bd6 100644
--- a/src/main/java/api/resources/doc/annotations/AnnotationsClient.java
+++ b/src/main/java/api/resources/doc/annotations/AnnotationsClient.java
@@ -13,6 +13,7 @@
import com.cloudpdf.api.resources.doc.annotations.requests.ListAllAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ListAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ReadAppearanceAnnotationsRequest;
+import com.cloudpdf.api.resources.doc.annotations.requests.ReadFileAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.UpdateAnnotationsRequest;
import com.cloudpdf.api.types.AnnotationList;
import com.cloudpdf.api.types.DocAnnotationsCreate200Response;
@@ -230,6 +231,48 @@ public InputStream readAppearance(
.body();
}
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream readFile(String docId, String layerName, String pageKey, String annotKey) {
+ return this.rawClient.readFile(docId, layerName, pageKey, annotKey).body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream readFile(
+ String docId, String layerName, String pageKey, String annotKey, RequestOptions requestOptions) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, requestOptions)
+ .body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream readFile(
+ String docId, String layerName, String pageKey, String annotKey, ReadFileAnnotationsRequest request) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, request)
+ .body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream readFile(
+ String docId,
+ String layerName,
+ String pageKey,
+ String annotKey,
+ ReadFileAnnotationsRequest request,
+ RequestOptions requestOptions) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, request, requestOptions)
+ .body();
+ }
+
public InputStream exportAppearance(String docId, String layerName, String pageKey, Map body) {
return this.rawClient.exportAppearance(docId, layerName, pageKey, body).body();
}
diff --git a/src/main/java/api/resources/doc/annotations/AsyncAnnotationsClient.java b/src/main/java/api/resources/doc/annotations/AsyncAnnotationsClient.java
index 58f23fb..8ddcc5d 100644
--- a/src/main/java/api/resources/doc/annotations/AsyncAnnotationsClient.java
+++ b/src/main/java/api/resources/doc/annotations/AsyncAnnotationsClient.java
@@ -13,6 +13,7 @@
import com.cloudpdf.api.resources.doc.annotations.requests.ListAllAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ListAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ReadAppearanceAnnotationsRequest;
+import com.cloudpdf.api.resources.doc.annotations.requests.ReadFileAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.UpdateAnnotationsRequest;
import com.cloudpdf.api.types.AnnotationList;
import com.cloudpdf.api.types.DocAnnotationsCreate200Response;
@@ -236,6 +237,48 @@ public CompletableFuture readAppearance(
.thenApply(response -> response.body());
}
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture readFile(String docId, String layerName, String pageKey, String annotKey) {
+ return this.rawClient.readFile(docId, layerName, pageKey, annotKey).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture readFile(
+ String docId, String layerName, String pageKey, String annotKey, RequestOptions requestOptions) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, requestOptions)
+ .thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture readFile(
+ String docId, String layerName, String pageKey, String annotKey, ReadFileAnnotationsRequest request) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, request)
+ .thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture readFile(
+ String docId,
+ String layerName,
+ String pageKey,
+ String annotKey,
+ ReadFileAnnotationsRequest request,
+ RequestOptions requestOptions) {
+ return this.rawClient
+ .readFile(docId, layerName, pageKey, annotKey, request, requestOptions)
+ .thenApply(response -> response.body());
+ }
+
public CompletableFuture exportAppearance(
String docId, String layerName, String pageKey, Map body) {
return this.rawClient.exportAppearance(docId, layerName, pageKey, body).thenApply(response -> response.body());
diff --git a/src/main/java/api/resources/doc/annotations/AsyncRawAnnotationsClient.java b/src/main/java/api/resources/doc/annotations/AsyncRawAnnotationsClient.java
index 0ccb504..03dedb7 100644
--- a/src/main/java/api/resources/doc/annotations/AsyncRawAnnotationsClient.java
+++ b/src/main/java/api/resources/doc/annotations/AsyncRawAnnotationsClient.java
@@ -14,6 +14,7 @@
import com.cloudpdf.api.core.RetryInterceptor;
import com.cloudpdf.api.errors.BadRequestError;
import com.cloudpdf.api.errors.ConflictError;
+import com.cloudpdf.api.errors.ContentTooLargeError;
import com.cloudpdf.api.errors.NotFoundError;
import com.cloudpdf.api.resources.doc.annotations.requests.CreateAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.DeleteAnnotationsRequest;
@@ -23,6 +24,7 @@
import com.cloudpdf.api.resources.doc.annotations.requests.ListAllAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ListAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ReadAppearanceAnnotationsRequest;
+import com.cloudpdf.api.resources.doc.annotations.requests.ReadFileAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.UpdateAnnotationsRequest;
import com.cloudpdf.api.types.AnnotationList;
import com.cloudpdf.api.types.DocAnnotationsCreate200Response;
@@ -782,6 +784,144 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
return future;
}
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> readFile(
+ String docId, String layerName, String pageKey, String annotKey) {
+ return readFile(
+ docId,
+ layerName,
+ pageKey,
+ annotKey,
+ ReadFileAnnotationsRequest.builder().build());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> readFile(
+ String docId, String layerName, String pageKey, String annotKey, RequestOptions requestOptions) {
+ return readFile(
+ docId,
+ layerName,
+ pageKey,
+ annotKey,
+ ReadFileAnnotationsRequest.builder().build(),
+ requestOptions);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> readFile(
+ String docId, String layerName, String pageKey, String annotKey, ReadFileAnnotationsRequest request) {
+ return readFile(docId, layerName, pageKey, annotKey, request, null);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> readFile(
+ String docId,
+ String layerName,
+ String pageKey,
+ String annotKey,
+ ReadFileAnnotationsRequest request,
+ RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("annotations/pages")
+ .addPathSegment(pageKey)
+ .addPathSegments("items")
+ .addPathSegment(annotKey)
+ .addPathSegments("resources")
+ .addPathSegments("file");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try {
+ ResponseBody responseBody = response.body();
+ if (response.isSuccessful()) {
+ future.complete(
+ new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ try {
+ switch (response.code()) {
+ case 400:
+ future.completeExceptionally(new BadRequestError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ case 404:
+ future.completeExceptionally(new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ case 413:
+ future.completeExceptionally(new ContentTooLargeError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ future.completeExceptionally(new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response));
+ return;
+ } catch (JsonProcessingException e) {
+ future.completeExceptionally(
+ new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
+ } catch (IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
public CompletableFuture> exportAppearance(
String docId, String layerName, String pageKey, Map body) {
return exportAppearance(
diff --git a/src/main/java/api/resources/doc/annotations/RawAnnotationsClient.java b/src/main/java/api/resources/doc/annotations/RawAnnotationsClient.java
index 5c19634..05ac7ab 100644
--- a/src/main/java/api/resources/doc/annotations/RawAnnotationsClient.java
+++ b/src/main/java/api/resources/doc/annotations/RawAnnotationsClient.java
@@ -14,6 +14,7 @@
import com.cloudpdf.api.core.RetryInterceptor;
import com.cloudpdf.api.errors.BadRequestError;
import com.cloudpdf.api.errors.ConflictError;
+import com.cloudpdf.api.errors.ContentTooLargeError;
import com.cloudpdf.api.errors.NotFoundError;
import com.cloudpdf.api.resources.doc.annotations.requests.CreateAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.DeleteAnnotationsRequest;
@@ -23,6 +24,7 @@
import com.cloudpdf.api.resources.doc.annotations.requests.ListAllAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ListAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.ReadAppearanceAnnotationsRequest;
+import com.cloudpdf.api.resources.doc.annotations.requests.ReadFileAnnotationsRequest;
import com.cloudpdf.api.resources.doc.annotations.requests.UpdateAnnotationsRequest;
import com.cloudpdf.api.types.AnnotationList;
import com.cloudpdf.api.types.DocAnnotationsCreate200Response;
@@ -666,6 +668,123 @@ public CloudPDFClientHttpResponse readAppearance(
}
}
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse readFile(
+ String docId, String layerName, String pageKey, String annotKey) {
+ return readFile(
+ docId,
+ layerName,
+ pageKey,
+ annotKey,
+ ReadFileAnnotationsRequest.builder().build());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse readFile(
+ String docId, String layerName, String pageKey, String annotKey, RequestOptions requestOptions) {
+ return readFile(
+ docId,
+ layerName,
+ pageKey,
+ annotKey,
+ ReadFileAnnotationsRequest.builder().build(),
+ requestOptions);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse readFile(
+ String docId, String layerName, String pageKey, String annotKey, ReadFileAnnotationsRequest request) {
+ return readFile(docId, layerName, pageKey, annotKey, request, null);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse readFile(
+ String docId,
+ String layerName,
+ String pageKey,
+ String annotKey,
+ ReadFileAnnotationsRequest request,
+ RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("annotations/pages")
+ .addPathSegment(pageKey)
+ .addPathSegments("items")
+ .addPathSegment(annotKey)
+ .addPathSegments("resources")
+ .addPathSegments("file");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ try {
+ Response response = client.newCall(okhttpRequest).execute();
+ ResponseBody responseBody = response.body();
+ if (response.isSuccessful()) {
+ return new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ try {
+ switch (response.code()) {
+ case 400:
+ throw new BadRequestError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 404:
+ throw new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 413:
+ throw new ContentTooLargeError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ throw new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response);
+ } catch (JsonProcessingException e) {
+ throw new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new CloudPDFException("Network error executing HTTP request", e);
+ }
+ }
+
public CloudPDFClientHttpResponse exportAppearance(
String docId, String layerName, String pageKey, Map body) {
return exportAppearance(
diff --git a/src/main/java/api/resources/doc/pages/requests/RotatePagesRequest.java b/src/main/java/api/resources/doc/annotations/requests/ReadFileAnnotationsRequest.java
similarity index 50%
rename from src/main/java/api/resources/doc/pages/requests/RotatePagesRequest.java
rename to src/main/java/api/resources/doc/annotations/requests/ReadFileAnnotationsRequest.java
index fe7a240..baa00d4 100644
--- a/src/main/java/api/resources/doc/pages/requests/RotatePagesRequest.java
+++ b/src/main/java/api/resources/doc/annotations/requests/ReadFileAnnotationsRequest.java
@@ -1,7 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.cloudpdf.api.resources.doc.pages.requests;
+package com.cloudpdf.api.resources.doc.annotations.requests;
import com.cloudpdf.api.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
@@ -9,35 +9,21 @@
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 java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
-@JsonDeserialize(builder = RotatePagesRequest.Builder.class)
-public final class RotatePagesRequest {
+@JsonDeserialize(builder = ReadFileAnnotationsRequest.Builder.class)
+public final class ReadFileAnnotationsRequest {
private final Optional documentPassword;
- private final Optional idempotencyKey;
-
- private final Map body;
-
private final Map additionalProperties;
- private RotatePagesRequest(
- Optional documentPassword,
- Optional idempotencyKey,
- Map body,
- Map additionalProperties) {
+ private ReadFileAnnotationsRequest(Optional documentPassword, Map additionalProperties) {
this.documentPassword = documentPassword;
- this.idempotencyKey = idempotencyKey;
- this.body = body;
this.additionalProperties = additionalProperties;
}
@@ -49,23 +35,10 @@ public Optional getDocumentPassword() {
return documentPassword;
}
- /**
- * @return Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- @JsonIgnore
- public Optional getIdempotencyKey() {
- return idempotencyKey;
- }
-
- @JsonProperty("body")
- public Map getBody() {
- return body;
- }
-
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
- return other instanceof RotatePagesRequest && equalTo((RotatePagesRequest) other);
+ return other instanceof ReadFileAnnotationsRequest && equalTo((ReadFileAnnotationsRequest) other);
}
@JsonAnyGetter
@@ -73,15 +46,13 @@ public Map getAdditionalProperties() {
return this.additionalProperties;
}
- private boolean equalTo(RotatePagesRequest other) {
- return documentPassword.equals(other.documentPassword)
- && idempotencyKey.equals(other.idempotencyKey)
- && body.equals(other.body);
+ private boolean equalTo(ReadFileAnnotationsRequest other) {
+ return documentPassword.equals(other.documentPassword);
}
@java.lang.Override
public int hashCode() {
- return Objects.hash(this.documentPassword, this.idempotencyKey, this.body);
+ return Objects.hash(this.documentPassword);
}
@java.lang.Override
@@ -97,19 +68,13 @@ public static Builder builder() {
public static final class Builder {
private Optional documentPassword = Optional.empty();
- private Optional idempotencyKey = Optional.empty();
-
- private Map body = new LinkedHashMap<>();
-
@JsonAnySetter
private Map additionalProperties = new HashMap<>();
private Builder() {}
- public Builder from(RotatePagesRequest other) {
+ public Builder from(ReadFileAnnotationsRequest other) {
documentPassword(other.getDocumentPassword());
- idempotencyKey(other.getIdempotencyKey());
- body(other.getBody());
return this;
}
@@ -126,42 +91,8 @@ public Builder documentPassword(String documentPassword) {
return this;
}
- /**
- * Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- public Builder idempotencyKey(Optional idempotencyKey) {
- this.idempotencyKey = idempotencyKey;
- return this;
- }
-
- public Builder idempotencyKey(String idempotencyKey) {
- this.idempotencyKey = Optional.ofNullable(idempotencyKey);
- return this;
- }
-
- @JsonSetter(value = "body", nulls = Nulls.SKIP)
- public Builder body(Map body) {
- this.body.clear();
- if (body != null) {
- this.body.putAll(body);
- }
- return this;
- }
-
- public Builder putAllBody(Map body) {
- if (body != null) {
- this.body.putAll(body);
- }
- return this;
- }
-
- public Builder body(String key, Object value) {
- this.body.put(key, value);
- return this;
- }
-
- public RotatePagesRequest build() {
- return new RotatePagesRequest(documentPassword, idempotencyKey, body, additionalProperties);
+ public ReadFileAnnotationsRequest build() {
+ return new ReadFileAnnotationsRequest(documentPassword, additionalProperties);
}
public Builder additionalProperty(String key, Object value) {
diff --git a/src/main/java/api/resources/doc/attachments/AsyncAttachmentsClient.java b/src/main/java/api/resources/doc/attachments/AsyncAttachmentsClient.java
new file mode 100644
index 0000000..bdaa49f
--- /dev/null
+++ b/src/main/java/api/resources/doc/attachments/AsyncAttachmentsClient.java
@@ -0,0 +1,98 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.attachments;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.resources.doc.attachments.requests.DownloadAttachmentsRequest;
+import com.cloudpdf.api.resources.doc.attachments.requests.ListAttachmentsRequest;
+import com.cloudpdf.api.types.AttachmentList;
+import java.io.InputStream;
+import java.util.concurrent.CompletableFuture;
+
+public class AsyncAttachmentsClient {
+ protected final ClientOptions clientOptions;
+
+ private final AsyncRawAttachmentsClient rawClient;
+
+ public AsyncAttachmentsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new AsyncRawAttachmentsClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public AsyncRawAttachmentsClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture download(String docId, String layerName, String fileKey) {
+ return this.rawClient.download(docId, layerName, fileKey).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture download(
+ String docId, String layerName, String fileKey, RequestOptions requestOptions) {
+ return this.rawClient
+ .download(docId, layerName, fileKey, requestOptions)
+ .thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture download(
+ String docId, String layerName, String fileKey, DownloadAttachmentsRequest request) {
+ return this.rawClient.download(docId, layerName, fileKey, request).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture download(
+ String docId,
+ String layerName,
+ String fileKey,
+ DownloadAttachmentsRequest request,
+ RequestOptions requestOptions) {
+ return this.rawClient
+ .download(docId, layerName, fileKey, request, requestOptions)
+ .thenApply(response -> response.body());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture list(String docId, String layerName) {
+ return this.rawClient.list(docId, layerName).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture list(String docId, String layerName, RequestOptions requestOptions) {
+ return this.rawClient.list(docId, layerName, requestOptions).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture list(String docId, String layerName, ListAttachmentsRequest request) {
+ return this.rawClient.list(docId, layerName, request).thenApply(response -> response.body());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture list(
+ String docId, String layerName, ListAttachmentsRequest request, RequestOptions requestOptions) {
+ return this.rawClient.list(docId, layerName, request, requestOptions).thenApply(response -> response.body());
+ }
+}
diff --git a/src/main/java/api/resources/doc/attachments/AsyncRawAttachmentsClient.java b/src/main/java/api/resources/doc/attachments/AsyncRawAttachmentsClient.java
new file mode 100644
index 0000000..086b2f1
--- /dev/null
+++ b/src/main/java/api/resources/doc/attachments/AsyncRawAttachmentsClient.java
@@ -0,0 +1,269 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.attachments;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.CloudPDFApiException;
+import com.cloudpdf.api.core.CloudPDFClientHttpResponse;
+import com.cloudpdf.api.core.CloudPDFException;
+import com.cloudpdf.api.core.ObjectMappers;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.core.ResponseBodyInputStream;
+import com.cloudpdf.api.core.RetryInterceptor;
+import com.cloudpdf.api.errors.BadRequestError;
+import com.cloudpdf.api.errors.ContentTooLargeError;
+import com.cloudpdf.api.errors.NotFoundError;
+import com.cloudpdf.api.resources.doc.attachments.requests.DownloadAttachmentsRequest;
+import com.cloudpdf.api.resources.doc.attachments.requests.ListAttachmentsRequest;
+import com.cloudpdf.api.types.AttachmentList;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.io.IOException;
+import java.io.InputStream;
+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.Response;
+import okhttp3.ResponseBody;
+import org.jetbrains.annotations.NotNull;
+
+public class AsyncRawAttachmentsClient {
+ protected final ClientOptions clientOptions;
+
+ public AsyncRawAttachmentsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> download(
+ String docId, String layerName, String fileKey) {
+ return download(
+ docId, layerName, fileKey, DownloadAttachmentsRequest.builder().build());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> download(
+ String docId, String layerName, String fileKey, RequestOptions requestOptions) {
+ return download(
+ docId, layerName, fileKey, DownloadAttachmentsRequest.builder().build(), requestOptions);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> download(
+ String docId, String layerName, String fileKey, DownloadAttachmentsRequest request) {
+ return download(docId, layerName, fileKey, request, null);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CompletableFuture> download(
+ String docId,
+ String layerName,
+ String fileKey,
+ DownloadAttachmentsRequest request,
+ RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("attachment-files")
+ .addPathSegment(fileKey)
+ .addPathSegments("data");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try {
+ ResponseBody responseBody = response.body();
+ if (response.isSuccessful()) {
+ future.complete(
+ new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response));
+ return;
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ try {
+ switch (response.code()) {
+ case 400:
+ future.completeExceptionally(new BadRequestError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ case 404:
+ future.completeExceptionally(new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ case 413:
+ future.completeExceptionally(new ContentTooLargeError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
+ response));
+ return;
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ future.completeExceptionally(new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response));
+ return;
+ } catch (JsonProcessingException e) {
+ future.completeExceptionally(
+ new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
+ } catch (IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture> list(String docId, String layerName) {
+ return list(docId, layerName, ListAttachmentsRequest.builder().build());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture> list(
+ String docId, String layerName, RequestOptions requestOptions) {
+ return list(docId, layerName, ListAttachmentsRequest.builder().build(), requestOptions);
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture> list(
+ String docId, String layerName, ListAttachmentsRequest request) {
+ return list(docId, layerName, request, null);
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CompletableFuture> list(
+ String docId, String layerName, ListAttachmentsRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("attachments");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ if (response.isSuccessful()) {
+ future.complete(new CloudPDFClientHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AttachmentList.class),
+ response));
+ return;
+ }
+ try {
+ if (response.code() == 404) {
+ future.completeExceptionally(new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
+ return;
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ future.completeExceptionally(new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response));
+ return;
+ } catch (JsonProcessingException e) {
+ future.completeExceptionally(
+ new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
+ } catch (IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+}
diff --git a/src/main/java/api/resources/doc/attachments/AttachmentsClient.java b/src/main/java/api/resources/doc/attachments/AttachmentsClient.java
new file mode 100644
index 0000000..ee869d8
--- /dev/null
+++ b/src/main/java/api/resources/doc/attachments/AttachmentsClient.java
@@ -0,0 +1,95 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.attachments;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.resources.doc.attachments.requests.DownloadAttachmentsRequest;
+import com.cloudpdf.api.resources.doc.attachments.requests.ListAttachmentsRequest;
+import com.cloudpdf.api.types.AttachmentList;
+import java.io.InputStream;
+
+public class AttachmentsClient {
+ protected final ClientOptions clientOptions;
+
+ private final RawAttachmentsClient rawClient;
+
+ public AttachmentsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new RawAttachmentsClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public RawAttachmentsClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream download(String docId, String layerName, String fileKey) {
+ return this.rawClient.download(docId, layerName, fileKey).body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream download(String docId, String layerName, String fileKey, RequestOptions requestOptions) {
+ return this.rawClient
+ .download(docId, layerName, fileKey, requestOptions)
+ .body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream download(String docId, String layerName, String fileKey, DownloadAttachmentsRequest request) {
+ return this.rawClient.download(docId, layerName, fileKey, request).body();
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public InputStream download(
+ String docId,
+ String layerName,
+ String fileKey,
+ DownloadAttachmentsRequest request,
+ RequestOptions requestOptions) {
+ return this.rawClient
+ .download(docId, layerName, fileKey, request, requestOptions)
+ .body();
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public AttachmentList list(String docId, String layerName) {
+ return this.rawClient.list(docId, layerName).body();
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public AttachmentList list(String docId, String layerName, RequestOptions requestOptions) {
+ return this.rawClient.list(docId, layerName, requestOptions).body();
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public AttachmentList list(String docId, String layerName, ListAttachmentsRequest request) {
+ return this.rawClient.list(docId, layerName, request).body();
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public AttachmentList list(
+ String docId, String layerName, ListAttachmentsRequest request, RequestOptions requestOptions) {
+ return this.rawClient.list(docId, layerName, request, requestOptions).body();
+ }
+}
diff --git a/src/main/java/api/resources/doc/attachments/RawAttachmentsClient.java b/src/main/java/api/resources/doc/attachments/RawAttachmentsClient.java
new file mode 100644
index 0000000..ed0c1d6
--- /dev/null
+++ b/src/main/java/api/resources/doc/attachments/RawAttachmentsClient.java
@@ -0,0 +1,227 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.attachments;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.CloudPDFApiException;
+import com.cloudpdf.api.core.CloudPDFClientHttpResponse;
+import com.cloudpdf.api.core.CloudPDFException;
+import com.cloudpdf.api.core.ObjectMappers;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.core.ResponseBodyInputStream;
+import com.cloudpdf.api.core.RetryInterceptor;
+import com.cloudpdf.api.errors.BadRequestError;
+import com.cloudpdf.api.errors.ContentTooLargeError;
+import com.cloudpdf.api.errors.NotFoundError;
+import com.cloudpdf.api.resources.doc.attachments.requests.DownloadAttachmentsRequest;
+import com.cloudpdf.api.resources.doc.attachments.requests.ListAttachmentsRequest;
+import com.cloudpdf.api.types.AttachmentList;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.io.IOException;
+import java.io.InputStream;
+import okhttp3.Headers;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+
+public class RawAttachmentsClient {
+ protected final ClientOptions clientOptions;
+
+ public RawAttachmentsClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse download(String docId, String layerName, String fileKey) {
+ return download(
+ docId, layerName, fileKey, DownloadAttachmentsRequest.builder().build());
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse download(
+ String docId, String layerName, String fileKey, RequestOptions requestOptions) {
+ return download(
+ docId, layerName, fileKey, DownloadAttachmentsRequest.builder().build(), requestOptions);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse download(
+ String docId, String layerName, String fileKey, DownloadAttachmentsRequest request) {
+ return download(docId, layerName, fileKey, request, null);
+ }
+
+ /**
+ * A file that decodes past the server's limit is refused (PayloadTooLarge).
+ */
+ public CloudPDFClientHttpResponse download(
+ String docId,
+ String layerName,
+ String fileKey,
+ DownloadAttachmentsRequest request,
+ RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("attachment-files")
+ .addPathSegment(fileKey)
+ .addPathSegments("data");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ try {
+ Response response = client.newCall(okhttpRequest).execute();
+ ResponseBody responseBody = response.body();
+ if (response.isSuccessful()) {
+ return new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response);
+ }
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ try {
+ switch (response.code()) {
+ case 400:
+ throw new BadRequestError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 404:
+ throw new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ case 413:
+ throw new ContentTooLargeError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ throw new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response);
+ } catch (JsonProcessingException e) {
+ throw new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new CloudPDFException("Network error executing HTTP request", e);
+ }
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CloudPDFClientHttpResponse list(String docId, String layerName) {
+ return list(docId, layerName, ListAttachmentsRequest.builder().build());
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CloudPDFClientHttpResponse list(
+ String docId, String layerName, RequestOptions requestOptions) {
+ return list(docId, layerName, ListAttachmentsRequest.builder().build(), requestOptions);
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CloudPDFClientHttpResponse list(
+ String docId, String layerName, ListAttachmentsRequest request) {
+ return list(docId, layerName, request, null);
+ }
+
+ /**
+ * A file-attachment annotation's file is listed with the annotation; read its bytes with doc.annotations.readFile.
+ */
+ public CloudPDFClientHttpResponse list(
+ String docId, String layerName, ListAttachmentsRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("attachments");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ try (Response response = client.newCall(okhttpRequest).execute()) {
+ ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ if (response.isSuccessful()) {
+ return new CloudPDFClientHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AttachmentList.class), response);
+ }
+ try {
+ if (response.code() == 404) {
+ throw new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ throw new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response);
+ } catch (JsonProcessingException e) {
+ throw new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new CloudPDFException("Network error executing HTTP request", e);
+ }
+ }
+}
diff --git a/src/main/java/api/resources/doc/pages/requests/DeletePagesRequest.java b/src/main/java/api/resources/doc/attachments/requests/DownloadAttachmentsRequest.java
similarity index 51%
rename from src/main/java/api/resources/doc/pages/requests/DeletePagesRequest.java
rename to src/main/java/api/resources/doc/attachments/requests/DownloadAttachmentsRequest.java
index ae1e525..926c5a0 100644
--- a/src/main/java/api/resources/doc/pages/requests/DeletePagesRequest.java
+++ b/src/main/java/api/resources/doc/attachments/requests/DownloadAttachmentsRequest.java
@@ -1,7 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.cloudpdf.api.resources.doc.pages.requests;
+package com.cloudpdf.api.resources.doc.attachments.requests;
import com.cloudpdf.api.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
@@ -9,35 +9,21 @@
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 java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
-@JsonDeserialize(builder = DeletePagesRequest.Builder.class)
-public final class DeletePagesRequest {
+@JsonDeserialize(builder = DownloadAttachmentsRequest.Builder.class)
+public final class DownloadAttachmentsRequest {
private final Optional documentPassword;
- private final Optional idempotencyKey;
-
- private final Map body;
-
private final Map additionalProperties;
- private DeletePagesRequest(
- Optional documentPassword,
- Optional idempotencyKey,
- Map body,
- Map additionalProperties) {
+ private DownloadAttachmentsRequest(Optional documentPassword, Map additionalProperties) {
this.documentPassword = documentPassword;
- this.idempotencyKey = idempotencyKey;
- this.body = body;
this.additionalProperties = additionalProperties;
}
@@ -49,23 +35,10 @@ public Optional getDocumentPassword() {
return documentPassword;
}
- /**
- * @return Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- @JsonIgnore
- public Optional getIdempotencyKey() {
- return idempotencyKey;
- }
-
- @JsonProperty("body")
- public Map getBody() {
- return body;
- }
-
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
- return other instanceof DeletePagesRequest && equalTo((DeletePagesRequest) other);
+ return other instanceof DownloadAttachmentsRequest && equalTo((DownloadAttachmentsRequest) other);
}
@JsonAnyGetter
@@ -73,15 +46,13 @@ public Map getAdditionalProperties() {
return this.additionalProperties;
}
- private boolean equalTo(DeletePagesRequest other) {
- return documentPassword.equals(other.documentPassword)
- && idempotencyKey.equals(other.idempotencyKey)
- && body.equals(other.body);
+ private boolean equalTo(DownloadAttachmentsRequest other) {
+ return documentPassword.equals(other.documentPassword);
}
@java.lang.Override
public int hashCode() {
- return Objects.hash(this.documentPassword, this.idempotencyKey, this.body);
+ return Objects.hash(this.documentPassword);
}
@java.lang.Override
@@ -97,19 +68,13 @@ public static Builder builder() {
public static final class Builder {
private Optional documentPassword = Optional.empty();
- private Optional idempotencyKey = Optional.empty();
-
- private Map body = new LinkedHashMap<>();
-
@JsonAnySetter
private Map additionalProperties = new HashMap<>();
private Builder() {}
- public Builder from(DeletePagesRequest other) {
+ public Builder from(DownloadAttachmentsRequest other) {
documentPassword(other.getDocumentPassword());
- idempotencyKey(other.getIdempotencyKey());
- body(other.getBody());
return this;
}
@@ -126,42 +91,8 @@ public Builder documentPassword(String documentPassword) {
return this;
}
- /**
- * Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- public Builder idempotencyKey(Optional idempotencyKey) {
- this.idempotencyKey = idempotencyKey;
- return this;
- }
-
- public Builder idempotencyKey(String idempotencyKey) {
- this.idempotencyKey = Optional.ofNullable(idempotencyKey);
- return this;
- }
-
- @JsonSetter(value = "body", nulls = Nulls.SKIP)
- public Builder body(Map body) {
- this.body.clear();
- if (body != null) {
- this.body.putAll(body);
- }
- return this;
- }
-
- public Builder putAllBody(Map body) {
- if (body != null) {
- this.body.putAll(body);
- }
- return this;
- }
-
- public Builder body(String key, Object value) {
- this.body.put(key, value);
- return this;
- }
-
- public DeletePagesRequest build() {
- return new DeletePagesRequest(documentPassword, idempotencyKey, body, additionalProperties);
+ public DownloadAttachmentsRequest build() {
+ return new DownloadAttachmentsRequest(documentPassword, additionalProperties);
}
public Builder additionalProperty(String key, Object value) {
diff --git a/src/main/java/api/resources/doc/pages/requests/InsertPagesRequest.java b/src/main/java/api/resources/doc/attachments/requests/ListAttachmentsRequest.java
similarity index 61%
rename from src/main/java/api/resources/doc/pages/requests/InsertPagesRequest.java
rename to src/main/java/api/resources/doc/attachments/requests/ListAttachmentsRequest.java
index e658983..c16ce57 100644
--- a/src/main/java/api/resources/doc/pages/requests/InsertPagesRequest.java
+++ b/src/main/java/api/resources/doc/attachments/requests/ListAttachmentsRequest.java
@@ -1,7 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
-package com.cloudpdf.api.resources.doc.pages.requests;
+package com.cloudpdf.api.resources.doc.attachments.requests;
import com.cloudpdf.api.core.ObjectMappers;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
@@ -16,20 +16,14 @@
import java.util.Optional;
@JsonInclude(JsonInclude.Include.NON_ABSENT)
-@JsonDeserialize(builder = InsertPagesRequest.Builder.class)
-public final class InsertPagesRequest {
+@JsonDeserialize(builder = ListAttachmentsRequest.Builder.class)
+public final class ListAttachmentsRequest {
private final Optional documentPassword;
- private final Optional idempotencyKey;
-
private final Map additionalProperties;
- private InsertPagesRequest(
- Optional documentPassword,
- Optional idempotencyKey,
- Map additionalProperties) {
+ private ListAttachmentsRequest(Optional documentPassword, Map additionalProperties) {
this.documentPassword = documentPassword;
- this.idempotencyKey = idempotencyKey;
this.additionalProperties = additionalProperties;
}
@@ -41,18 +35,10 @@ public Optional getDocumentPassword() {
return documentPassword;
}
- /**
- * @return Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- @JsonIgnore
- public Optional getIdempotencyKey() {
- return idempotencyKey;
- }
-
@java.lang.Override
public boolean equals(Object other) {
if (this == other) return true;
- return other instanceof InsertPagesRequest && equalTo((InsertPagesRequest) other);
+ return other instanceof ListAttachmentsRequest && equalTo((ListAttachmentsRequest) other);
}
@JsonAnyGetter
@@ -60,13 +46,13 @@ public Map getAdditionalProperties() {
return this.additionalProperties;
}
- private boolean equalTo(InsertPagesRequest other) {
- return documentPassword.equals(other.documentPassword) && idempotencyKey.equals(other.idempotencyKey);
+ private boolean equalTo(ListAttachmentsRequest other) {
+ return documentPassword.equals(other.documentPassword);
}
@java.lang.Override
public int hashCode() {
- return Objects.hash(this.documentPassword, this.idempotencyKey);
+ return Objects.hash(this.documentPassword);
}
@java.lang.Override
@@ -82,16 +68,13 @@ public static Builder builder() {
public static final class Builder {
private Optional documentPassword = Optional.empty();
- private Optional idempotencyKey = Optional.empty();
-
@JsonAnySetter
private Map additionalProperties = new HashMap<>();
private Builder() {}
- public Builder from(InsertPagesRequest other) {
+ public Builder from(ListAttachmentsRequest other) {
documentPassword(other.getDocumentPassword());
- idempotencyKey(other.getIdempotencyKey());
return this;
}
@@ -108,21 +91,8 @@ public Builder documentPassword(String documentPassword) {
return this;
}
- /**
- * Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.
- */
- public Builder idempotencyKey(Optional idempotencyKey) {
- this.idempotencyKey = idempotencyKey;
- return this;
- }
-
- public Builder idempotencyKey(String idempotencyKey) {
- this.idempotencyKey = Optional.ofNullable(idempotencyKey);
- return this;
- }
-
- public InsertPagesRequest build() {
- return new InsertPagesRequest(documentPassword, idempotencyKey, additionalProperties);
+ public ListAttachmentsRequest build() {
+ return new ListAttachmentsRequest(documentPassword, additionalProperties);
}
public Builder additionalProperty(String key, Object value) {
diff --git a/src/main/java/api/resources/doc/outline/AsyncOutlineClient.java b/src/main/java/api/resources/doc/outline/AsyncOutlineClient.java
new file mode 100644
index 0000000..92b8129
--- /dev/null
+++ b/src/main/java/api/resources/doc/outline/AsyncOutlineClient.java
@@ -0,0 +1,45 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.outline;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.resources.doc.outline.requests.GetOutlineRequest;
+import com.cloudpdf.api.types.DocumentOutline;
+import java.util.concurrent.CompletableFuture;
+
+public class AsyncOutlineClient {
+ protected final ClientOptions clientOptions;
+
+ private final AsyncRawOutlineClient rawClient;
+
+ public AsyncOutlineClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new AsyncRawOutlineClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public AsyncRawOutlineClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ public CompletableFuture get(String docId, String layerName) {
+ return this.rawClient.get(docId, layerName).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture get(String docId, String layerName, RequestOptions requestOptions) {
+ return this.rawClient.get(docId, layerName, requestOptions).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture get(String docId, String layerName, GetOutlineRequest request) {
+ return this.rawClient.get(docId, layerName, request).thenApply(response -> response.body());
+ }
+
+ public CompletableFuture get(
+ String docId, String layerName, GetOutlineRequest request, RequestOptions requestOptions) {
+ return this.rawClient.get(docId, layerName, request, requestOptions).thenApply(response -> response.body());
+ }
+}
diff --git a/src/main/java/api/resources/doc/outline/AsyncRawOutlineClient.java b/src/main/java/api/resources/doc/outline/AsyncRawOutlineClient.java
new file mode 100644
index 0000000..6d8e044
--- /dev/null
+++ b/src/main/java/api/resources/doc/outline/AsyncRawOutlineClient.java
@@ -0,0 +1,127 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.outline;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.CloudPDFApiException;
+import com.cloudpdf.api.core.CloudPDFClientHttpResponse;
+import com.cloudpdf.api.core.CloudPDFException;
+import com.cloudpdf.api.core.ObjectMappers;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.core.RetryInterceptor;
+import com.cloudpdf.api.errors.NotFoundError;
+import com.cloudpdf.api.resources.doc.outline.requests.GetOutlineRequest;
+import com.cloudpdf.api.types.DocumentOutline;
+import com.fasterxml.jackson.core.JsonProcessingException;
+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.Response;
+import okhttp3.ResponseBody;
+import org.jetbrains.annotations.NotNull;
+
+public class AsyncRawOutlineClient {
+ protected final ClientOptions clientOptions;
+
+ public AsyncRawOutlineClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ public CompletableFuture> get(String docId, String layerName) {
+ return get(docId, layerName, GetOutlineRequest.builder().build());
+ }
+
+ public CompletableFuture> get(
+ String docId, String layerName, RequestOptions requestOptions) {
+ return get(docId, layerName, GetOutlineRequest.builder().build(), requestOptions);
+ }
+
+ public CompletableFuture> get(
+ String docId, String layerName, GetOutlineRequest request) {
+ return get(docId, layerName, request, null);
+ }
+
+ public CompletableFuture> get(
+ String docId, String layerName, GetOutlineRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("outline");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ CompletableFuture> future = new CompletableFuture<>();
+ client.newCall(okhttpRequest).enqueue(new Callback() {
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody responseBody = response.body()) {
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ if (response.isSuccessful()) {
+ future.complete(new CloudPDFClientHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DocumentOutline.class),
+ response));
+ return;
+ }
+ try {
+ if (response.code() == 404) {
+ future.completeExceptionally(new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
+ return;
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ future.completeExceptionally(new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response));
+ return;
+ } catch (JsonProcessingException e) {
+ future.completeExceptionally(
+ new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
+ } catch (IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
+ }
+ });
+ return future;
+ }
+}
diff --git a/src/main/java/api/resources/doc/outline/OutlineClient.java b/src/main/java/api/resources/doc/outline/OutlineClient.java
new file mode 100644
index 0000000..5a14ba0
--- /dev/null
+++ b/src/main/java/api/resources/doc/outline/OutlineClient.java
@@ -0,0 +1,44 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.outline;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.resources.doc.outline.requests.GetOutlineRequest;
+import com.cloudpdf.api.types.DocumentOutline;
+
+public class OutlineClient {
+ protected final ClientOptions clientOptions;
+
+ private final RawOutlineClient rawClient;
+
+ public OutlineClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ this.rawClient = new RawOutlineClient(clientOptions);
+ }
+
+ /**
+ * Get responses with HTTP metadata like headers
+ */
+ public RawOutlineClient withRawResponse() {
+ return this.rawClient;
+ }
+
+ public DocumentOutline get(String docId, String layerName) {
+ return this.rawClient.get(docId, layerName).body();
+ }
+
+ public DocumentOutline get(String docId, String layerName, RequestOptions requestOptions) {
+ return this.rawClient.get(docId, layerName, requestOptions).body();
+ }
+
+ public DocumentOutline get(String docId, String layerName, GetOutlineRequest request) {
+ return this.rawClient.get(docId, layerName, request).body();
+ }
+
+ public DocumentOutline get(
+ String docId, String layerName, GetOutlineRequest request, RequestOptions requestOptions) {
+ return this.rawClient.get(docId, layerName, request, requestOptions).body();
+ }
+}
diff --git a/src/main/java/api/resources/doc/outline/RawOutlineClient.java b/src/main/java/api/resources/doc/outline/RawOutlineClient.java
new file mode 100644
index 0000000..a994b6a
--- /dev/null
+++ b/src/main/java/api/resources/doc/outline/RawOutlineClient.java
@@ -0,0 +1,106 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.outline;
+
+import com.cloudpdf.api.core.ClientOptions;
+import com.cloudpdf.api.core.CloudPDFApiException;
+import com.cloudpdf.api.core.CloudPDFClientHttpResponse;
+import com.cloudpdf.api.core.CloudPDFException;
+import com.cloudpdf.api.core.ObjectMappers;
+import com.cloudpdf.api.core.RequestOptions;
+import com.cloudpdf.api.core.RetryInterceptor;
+import com.cloudpdf.api.errors.NotFoundError;
+import com.cloudpdf.api.resources.doc.outline.requests.GetOutlineRequest;
+import com.cloudpdf.api.types.DocumentOutline;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import java.io.IOException;
+import okhttp3.Headers;
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+
+public class RawOutlineClient {
+ protected final ClientOptions clientOptions;
+
+ public RawOutlineClient(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ }
+
+ public CloudPDFClientHttpResponse get(String docId, String layerName) {
+ return get(docId, layerName, GetOutlineRequest.builder().build());
+ }
+
+ public CloudPDFClientHttpResponse get(
+ String docId, String layerName, RequestOptions requestOptions) {
+ return get(docId, layerName, GetOutlineRequest.builder().build(), requestOptions);
+ }
+
+ public CloudPDFClientHttpResponse get(String docId, String layerName, GetOutlineRequest request) {
+ return get(docId, layerName, request, null);
+ }
+
+ public CloudPDFClientHttpResponse get(
+ String docId, String layerName, GetOutlineRequest request, RequestOptions requestOptions) {
+ HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
+ .newBuilder()
+ .addPathSegments("v1/docs")
+ .addPathSegment(docId)
+ .addPathSegments("layers")
+ .addPathSegment(layerName)
+ .addPathSegments("outline");
+ 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");
+ if (request.getDocumentPassword().isPresent()) {
+ _requestBuilder.addHeader(
+ "X-Document-Password", request.getDocumentPassword().get());
+ }
+ Request okhttpRequest = _requestBuilder.build();
+ OkHttpClient client = clientOptions.httpClient();
+ if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
+ client = clientOptions.httpClientWithTimeout(requestOptions);
+ }
+ if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
+ okhttpRequest = okhttpRequest
+ .newBuilder()
+ .tag(
+ RetryInterceptor.MaxRetriesOverride.class,
+ new RetryInterceptor.MaxRetriesOverride(
+ requestOptions.getMaxRetries().get()))
+ .build();
+ }
+ try (Response response = client.newCall(okhttpRequest).execute()) {
+ ResponseBody responseBody = response.body();
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
+ if (response.isSuccessful()) {
+ return new CloudPDFClientHttpResponse<>(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DocumentOutline.class), response);
+ }
+ try {
+ if (response.code() == 404) {
+ throw new NotFoundError(
+ ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
+ }
+ } catch (JsonProcessingException ignored) {
+ // unable to map error response, throwing generic error
+ }
+ Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
+ throw new CloudPDFApiException(
+ "Error with status code " + response.code(), response.code(), errorBody, response);
+ } catch (JsonProcessingException e) {
+ throw new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new CloudPDFException("Network error executing HTTP request", e);
+ }
+ }
+}
diff --git a/src/main/java/api/resources/doc/outline/requests/GetOutlineRequest.java b/src/main/java/api/resources/doc/outline/requests/GetOutlineRequest.java
new file mode 100644
index 0000000..dc24ac9
--- /dev/null
+++ b/src/main/java/api/resources/doc/outline/requests/GetOutlineRequest.java
@@ -0,0 +1,108 @@
+/**
+ * This file was auto-generated by Fern from our API Definition.
+ */
+package com.cloudpdf.api.resources.doc.outline.requests;
+
+import com.cloudpdf.api.core.ObjectMappers;
+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.databind.annotation.JsonDeserialize;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+@JsonInclude(JsonInclude.Include.NON_ABSENT)
+@JsonDeserialize(builder = GetOutlineRequest.Builder.class)
+public final class GetOutlineRequest {
+ private final Optional documentPassword;
+
+ private final Map additionalProperties;
+
+ private GetOutlineRequest(Optional documentPassword, Map additionalProperties) {
+ this.documentPassword = documentPassword;
+ this.additionalProperties = additionalProperties;
+ }
+
+ /**
+ * @return Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+ */
+ @JsonIgnore
+ public Optional getDocumentPassword() {
+ return documentPassword;
+ }
+
+ @java.lang.Override
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ return other instanceof GetOutlineRequest && equalTo((GetOutlineRequest) other);
+ }
+
+ @JsonAnyGetter
+ public Map getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ private boolean equalTo(GetOutlineRequest other) {
+ return documentPassword.equals(other.documentPassword);
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ return Objects.hash(this.documentPassword);
+ }
+
+ @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 documentPassword = Optional.empty();
+
+ @JsonAnySetter
+ private Map additionalProperties = new HashMap<>();
+
+ private Builder() {}
+
+ public Builder from(GetOutlineRequest other) {
+ documentPassword(other.getDocumentPassword());
+ return this;
+ }
+
+ /**
+ * Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
+ */
+ public Builder documentPassword(Optional documentPassword) {
+ this.documentPassword = documentPassword;
+ return this;
+ }
+
+ public Builder documentPassword(String documentPassword) {
+ this.documentPassword = Optional.ofNullable(documentPassword);
+ return this;
+ }
+
+ public GetOutlineRequest build() {
+ return new GetOutlineRequest(documentPassword, 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/api/resources/doc/pages/AsyncPagesClient.java b/src/main/java/api/resources/doc/pages/AsyncPagesClient.java
index eeb59f7..adf7f55 100644
--- a/src/main/java/api/resources/doc/pages/AsyncPagesClient.java
+++ b/src/main/java/api/resources/doc/pages/AsyncPagesClient.java
@@ -5,32 +5,20 @@
import com.cloudpdf.api.core.ClientOptions;
import com.cloudpdf.api.core.RequestOptions;
-import com.cloudpdf.api.resources.doc.pages.requests.DeletePagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.DocPagesReorderRequest;
import com.cloudpdf.api.resources.doc.pages.requests.DocPagesSetScaleRequest;
import com.cloudpdf.api.resources.doc.pages.requests.ExtractPagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.FlattenPagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.InsertBlankPagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.InsertPagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.RemoveNamePagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.RotatePagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.SetNamePagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.ViewportsPagesRequest;
-import com.cloudpdf.api.types.DocPagesDelete200Response;
import com.cloudpdf.api.types.DocPagesFlatten200Response;
-import com.cloudpdf.api.types.DocPagesInsert200Response;
-import com.cloudpdf.api.types.DocPagesInsertBlank200Response;
import com.cloudpdf.api.types.DocPagesRemoveName200Response;
-import com.cloudpdf.api.types.DocPagesReorder200Response;
-import com.cloudpdf.api.types.DocPagesRotate200Response;
import com.cloudpdf.api.types.DocPagesSetName200Response;
import com.cloudpdf.api.types.DocPagesSetScale200Response;
import com.cloudpdf.api.types.DocPagesViewports200Response;
-import java.io.File;
import java.io.InputStream;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import okhttp3.MediaType;
public class AsyncPagesClient {
protected final ClientOptions clientOptions;
@@ -92,35 +80,15 @@ public CompletableFuture viewports(
.thenApply(response -> response.body());
}
- public CompletableFuture delete(
- String docId, String layerName, Map body) {
- return this.rawClient.delete(docId, layerName, body).thenApply(response -> response.body());
- }
-
- public CompletableFuture delete(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return this.rawClient.delete(docId, layerName, body, requestOptions).thenApply(response -> response.body());
- }
-
- public CompletableFuture delete(
- String docId, String layerName, DeletePagesRequest request) {
- return this.rawClient.delete(docId, layerName, request).thenApply(response -> response.body());
- }
-
- public CompletableFuture delete(
- String docId, String layerName, DeletePagesRequest request, RequestOptions requestOptions) {
- return this.rawClient.delete(docId, layerName, request, requestOptions).thenApply(response -> response.body());
- }
-
/**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
public CompletableFuture extract(String docId, String layerName, Map body) {
return this.rawClient.extract(docId, layerName, body).thenApply(response -> response.body());
}
/**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
public CompletableFuture extract(
String docId, String layerName, Map body, RequestOptions requestOptions) {
@@ -128,14 +96,14 @@ public CompletableFuture extract(
}
/**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
public CompletableFuture extract(String docId, String layerName, ExtractPagesRequest request) {
return this.rawClient.extract(docId, layerName, request).thenApply(response -> response.body());
}
/**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
public CompletableFuture extract(
String docId, String layerName, ExtractPagesRequest request, RequestOptions requestOptions) {
@@ -162,91 +130,6 @@ public CompletableFuture flatten(
return this.rawClient.flatten(docId, layerName, request, requestOptions).thenApply(response -> response.body());
}
- /**
- * Multipart: a JSON body part {"position"?: PagePosition, "resources": {"source": "<key>"}} (position omitted → the end), and the standalone PDF whose pages are copied in as the part resource:<key>. The inserted copies get fresh page object numbers, returned in insertion order.
- */
- public CompletableFuture insert(
- String docId, String layerName, File file, InsertPagesRequest request) {
- return this.rawClient.insert(docId, layerName, file, request).thenApply(response -> response.body());
- }
-
- /**
- * Multipart: a JSON body part {"position"?: PagePosition, "resources": {"source": "<key>"}} (position omitted → the end), and the standalone PDF whose pages are copied in as the part resource:<key>. The inserted copies get fresh page object numbers, returned in insertion order.
- */
- public CompletableFuture insert(
- String docId, String layerName, File file, InsertPagesRequest request, RequestOptions requestOptions) {
- return this.rawClient
- .insert(docId, layerName, file, request, requestOptions)
- .thenApply(response -> response.body());
- }
-
- public CompletableFuture insert(
- String docId, String layerName, InputStream stream, String filename) {
- return this.rawClient.insert(docId, layerName, stream, filename).thenApply(response -> response.body());
- }
-
- public CompletableFuture insert(
- String docId, String layerName, InputStream stream, String filename, MediaType mediaType) {
- return this.rawClient
- .insert(docId, layerName, stream, filename, mediaType)
- .thenApply(response -> response.body());
- }
-
- public CompletableFuture insert(
- String docId, String layerName, InputStream stream, String filename, RequestOptions requestOptions) {
- return this.rawClient
- .insert(docId, layerName, stream, filename, requestOptions)
- .thenApply(response -> response.body());
- }
-
- public CompletableFuture insert(
- String docId,
- String layerName,
- InputStream stream,
- String filename,
- MediaType mediaType,
- RequestOptions requestOptions) {
- return this.rawClient
- .insert(docId, layerName, stream, filename, mediaType, requestOptions)
- .thenApply(response -> response.body());
- }
-
- /**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
- */
- public CompletableFuture insertBlank(
- String docId, String layerName, Map body) {
- return this.rawClient.insertBlank(docId, layerName, body).thenApply(response -> response.body());
- }
-
- /**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
- */
- public CompletableFuture insertBlank(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return this.rawClient
- .insertBlank(docId, layerName, body, requestOptions)
- .thenApply(response -> response.body());
- }
-
- /**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
- */
- public CompletableFuture insertBlank(
- String docId, String layerName, InsertBlankPagesRequest request) {
- return this.rawClient.insertBlank(docId, layerName, request).thenApply(response -> response.body());
- }
-
- /**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
- */
- public CompletableFuture insertBlank(
- String docId, String layerName, InsertBlankPagesRequest request, RequestOptions requestOptions) {
- return this.rawClient
- .insertBlank(docId, layerName, request, requestOptions)
- .thenApply(response -> response.body());
- }
-
public CompletableFuture setName(
String docId, String layerName, Map body) {
return this.rawClient.setName(docId, layerName, body).thenApply(response -> response.body());
@@ -288,34 +171,4 @@ public CompletableFuture removeName(
.removeName(docId, layerName, request, requestOptions)
.thenApply(response -> response.body());
}
-
- public CompletableFuture reorder(
- String docId, String layerName, DocPagesReorderRequest request) {
- return this.rawClient.reorder(docId, layerName, request).thenApply(response -> response.body());
- }
-
- public CompletableFuture reorder(
- String docId, String layerName, DocPagesReorderRequest request, RequestOptions requestOptions) {
- return this.rawClient.reorder(docId, layerName, request, requestOptions).thenApply(response -> response.body());
- }
-
- public CompletableFuture rotate(
- String docId, String layerName, Map body) {
- return this.rawClient.rotate(docId, layerName, body).thenApply(response -> response.body());
- }
-
- public CompletableFuture rotate(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return this.rawClient.rotate(docId, layerName, body, requestOptions).thenApply(response -> response.body());
- }
-
- public CompletableFuture rotate(
- String docId, String layerName, RotatePagesRequest request) {
- return this.rawClient.rotate(docId, layerName, request).thenApply(response -> response.body());
- }
-
- public CompletableFuture rotate(
- String docId, String layerName, RotatePagesRequest request, RequestOptions requestOptions) {
- return this.rawClient.rotate(docId, layerName, request, requestOptions).thenApply(response -> response.body());
- }
}
diff --git a/src/main/java/api/resources/doc/pages/AsyncRawPagesClient.java b/src/main/java/api/resources/doc/pages/AsyncRawPagesClient.java
index e43dffd..2368795 100644
--- a/src/main/java/api/resources/doc/pages/AsyncRawPagesClient.java
+++ b/src/main/java/api/resources/doc/pages/AsyncRawPagesClient.java
@@ -7,7 +7,6 @@
import com.cloudpdf.api.core.CloudPDFApiException;
import com.cloudpdf.api.core.CloudPDFClientHttpResponse;
import com.cloudpdf.api.core.CloudPDFException;
-import com.cloudpdf.api.core.FileStream;
import com.cloudpdf.api.core.MediaTypes;
import com.cloudpdf.api.core.ObjectMappers;
import com.cloudpdf.api.core.RequestOptions;
@@ -15,40 +14,26 @@
import com.cloudpdf.api.core.RetryInterceptor;
import com.cloudpdf.api.errors.BadRequestError;
import com.cloudpdf.api.errors.NotFoundError;
-import com.cloudpdf.api.resources.doc.pages.requests.DeletePagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.DocPagesReorderRequest;
import com.cloudpdf.api.resources.doc.pages.requests.DocPagesSetScaleRequest;
import com.cloudpdf.api.resources.doc.pages.requests.ExtractPagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.FlattenPagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.InsertBlankPagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.InsertPagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.RemoveNamePagesRequest;
-import com.cloudpdf.api.resources.doc.pages.requests.RotatePagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.SetNamePagesRequest;
import com.cloudpdf.api.resources.doc.pages.requests.ViewportsPagesRequest;
-import com.cloudpdf.api.types.DocPagesDelete200Response;
import com.cloudpdf.api.types.DocPagesFlatten200Response;
-import com.cloudpdf.api.types.DocPagesInsert200Response;
-import com.cloudpdf.api.types.DocPagesInsertBlank200Response;
import com.cloudpdf.api.types.DocPagesRemoveName200Response;
-import com.cloudpdf.api.types.DocPagesReorder200Response;
-import com.cloudpdf.api.types.DocPagesRotate200Response;
import com.cloudpdf.api.types.DocPagesSetName200Response;
import com.cloudpdf.api.types.DocPagesSetScale200Response;
import com.cloudpdf.api.types.DocPagesViewports200Response;
import com.fasterxml.jackson.core.JsonProcessingException;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.file.Files;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Headers;
import okhttp3.HttpUrl;
-import okhttp3.MediaType;
-import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
@@ -274,816 +259,37 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
return future;
}
- public CompletableFuture> delete(
- String docId, String layerName, Map body) {
- return delete(docId, layerName, DeletePagesRequest.builder().body(body).build());
- }
-
- public CompletableFuture> delete(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return delete(docId, layerName, DeletePagesRequest.builder().body(body).build(), requestOptions);
- }
-
- public CompletableFuture> delete(
- String docId, String layerName, DeletePagesRequest request) {
- return delete(docId, layerName, request, null);
- }
-
- public CompletableFuture> delete(
- String docId, String layerName, DeletePagesRequest request, RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("delete");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- RequestBody body;
- try {
- body = RequestBody.create(
- ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Request.Builder _requestBuilder = new Request.Builder()
- .url(httpUrl.build())
- .method("POST", body)
- .headers(Headers.of(clientOptions.headers(requestOptions)))
- .addHeader("Content-Type", "application/json")
- .addHeader("Accept", "application/json");
- if (request.getDocumentPassword().isPresent()) {
- _requestBuilder.addHeader(
- "X-Document-Password", request.getDocumentPassword().get());
- }
- if (request.getIdempotencyKey().isPresent()) {
- _requestBuilder.addHeader(
- "Idempotency-Key", request.getIdempotencyKey().get());
- }
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try (ResponseBody responseBody = response.body()) {
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesDelete200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- /**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
- */
- public CompletableFuture> extract(
- String docId, String layerName, Map body) {
- return extract(
- docId, layerName, ExtractPagesRequest.builder().body(body).build());
- }
-
- /**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
- */
- public CompletableFuture> extract(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return extract(
- docId, layerName, ExtractPagesRequest.builder().body(body).build(), requestOptions);
- }
-
- /**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
- */
- public CompletableFuture> extract(
- String docId, String layerName, ExtractPagesRequest request) {
- return extract(docId, layerName, request, null);
- }
-
- /**
- * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[]}; the response body is the new PDF.
- */
- public CompletableFuture> extract(
- String docId, String layerName, ExtractPagesRequest request, RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("extract");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- RequestBody body;
- try {
- body = RequestBody.create(
- ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Request.Builder _requestBuilder = new Request.Builder()
- .url(httpUrl.build())
- .method("POST", body)
- .headers(Headers.of(clientOptions.headers(requestOptions)))
- .addHeader("Content-Type", "application/json")
- .addHeader("Accept", "application/json");
- if (request.getDocumentPassword().isPresent()) {
- _requestBuilder.addHeader(
- "X-Document-Password", request.getDocumentPassword().get());
- }
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try {
- ResponseBody responseBody = response.body();
- if (response.isSuccessful()) {
- future.complete(
- new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response));
- return;
- }
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- public CompletableFuture> flatten(
- String docId, String layerName, Map body) {
- return flatten(
- docId, layerName, FlattenPagesRequest.builder().body(body).build());
- }
-
- public CompletableFuture> flatten(
- String docId, String layerName, Map body, RequestOptions requestOptions) {
- return flatten(
- docId, layerName, FlattenPagesRequest.builder().body(body).build(), requestOptions);
- }
-
- public CompletableFuture> flatten(
- String docId, String layerName, FlattenPagesRequest request) {
- return flatten(docId, layerName, request, null);
- }
-
- public CompletableFuture> flatten(
- String docId, String layerName, FlattenPagesRequest request, RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("flatten");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- RequestBody body;
- try {
- body = RequestBody.create(
- ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Request.Builder _requestBuilder = new Request.Builder()
- .url(httpUrl.build())
- .method("POST", body)
- .headers(Headers.of(clientOptions.headers(requestOptions)))
- .addHeader("Content-Type", "application/json")
- .addHeader("Accept", "application/json");
- if (request.getDocumentPassword().isPresent()) {
- _requestBuilder.addHeader(
- "X-Document-Password", request.getDocumentPassword().get());
- }
- if (request.getIdempotencyKey().isPresent()) {
- _requestBuilder.addHeader(
- "Idempotency-Key", request.getIdempotencyKey().get());
- }
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try (ResponseBody responseBody = response.body()) {
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesFlatten200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- /**
- * Multipart: a JSON body part {"position"?: PagePosition, "resources": {"source": "<key>"}} (position omitted → the end), and the standalone PDF whose pages are copied in as the part resource:<key>. The inserted copies get fresh page object numbers, returned in insertion order.
- */
- public CompletableFuture> insert(
- String docId, String layerName, File file, InsertPagesRequest request) {
- return insert(docId, layerName, file, request, null);
- }
-
- /**
- * Multipart: a JSON body part {"position"?: PagePosition, "resources": {"source": "<key>"}} (position omitted → the end), and the standalone PDF whose pages are copied in as the part resource:<key>. The inserted copies get fresh page object numbers, returned in insertion order.
- */
- public CompletableFuture> insert(
- String docId, String layerName, File file, InsertPagesRequest request, RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("insert");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- try {
- String fileMimeType = Files.probeContentType(file.toPath());
- MediaType fileMimeTypeMediaType = fileMimeType != null ? MediaType.parse(fileMimeType) : null;
- multipartBodyBuilder.addFormDataPart(
- "file", file.getName(), RequestBody.create(file, fileMimeTypeMediaType));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Request.Builder _requestBuilder = new Request.Builder()
- .url(httpUrl.build())
- .method("POST", multipartBodyBuilder.build())
- .headers(Headers.of(clientOptions.headers(requestOptions)))
- .addHeader("Accept", "application/json");
- if (request.getDocumentPassword().isPresent()) {
- _requestBuilder.addHeader(
- "X-Document-Password", request.getDocumentPassword().get());
- }
- if (request.getIdempotencyKey().isPresent()) {
- _requestBuilder.addHeader(
- "Idempotency-Key", request.getIdempotencyKey().get());
- }
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try (ResponseBody responseBody = response.body()) {
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsert200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- public CompletableFuture> insert(
- String docId, String layerName, InputStream stream, String filename) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("insert");
- FileStream fs = new FileStream(stream, filename, null);
- MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- multipartBodyBuilder.addFormDataPart("file", filename, fs.toRequestBody());
- RequestBody body = multipartBodyBuilder.build();
- Request.Builder _requestBuilder = new Request.Builder();
- _requestBuilder.url(httpUrl.build());
- _requestBuilder.method("POST", body);
- _requestBuilder.headers(Headers.of(this.clientOptions.headers((RequestOptions) null)));
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- 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 CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsert200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- public CompletableFuture> insert(
- String docId, String layerName, InputStream stream, String filename, MediaType mediaType) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("insert");
- FileStream fs = new FileStream(stream, filename, mediaType);
- MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- multipartBodyBuilder.addFormDataPart("file", filename, fs.toRequestBody());
- RequestBody body = multipartBodyBuilder.build();
- Request.Builder _requestBuilder = new Request.Builder();
- _requestBuilder.url(httpUrl.build());
- _requestBuilder.method("POST", body);
- _requestBuilder.headers(Headers.of(this.clientOptions.headers((RequestOptions) null)));
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- 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 CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsert200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- public CompletableFuture> insert(
- String docId, String layerName, InputStream stream, String filename, RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("insert");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- FileStream fs = new FileStream(stream, filename, null);
- MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- multipartBodyBuilder.addFormDataPart("file", filename, fs.toRequestBody());
- RequestBody body = multipartBodyBuilder.build();
- Request.Builder _requestBuilder = new Request.Builder();
- _requestBuilder.url(httpUrl.build());
- _requestBuilder.method("POST", body);
- _requestBuilder.headers(Headers.of(this.clientOptions.headers(requestOptions)));
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try (ResponseBody responseBody = response.body()) {
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsert200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
- public CompletableFuture> insert(
- String docId,
- String layerName,
- InputStream stream,
- String filename,
- MediaType mediaType,
- RequestOptions requestOptions) {
- HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
- .newBuilder()
- .addPathSegments("v1/docs")
- .addPathSegment(docId)
- .addPathSegments("layers")
- .addPathSegment(layerName)
- .addPathSegments("pages")
- .addPathSegments("insert");
- if (requestOptions != null) {
- requestOptions.getQueryParameters().forEach((_key, _value) -> {
- httpUrl.addQueryParameter(_key, _value);
- });
- }
- FileStream fs = new FileStream(stream, filename, mediaType);
- MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- multipartBodyBuilder.addFormDataPart("file", filename, fs.toRequestBody());
- RequestBody body = multipartBodyBuilder.build();
- Request.Builder _requestBuilder = new Request.Builder();
- _requestBuilder.url(httpUrl.build());
- _requestBuilder.method("POST", body);
- _requestBuilder.headers(Headers.of(this.clientOptions.headers(requestOptions)));
- Request okhttpRequest = _requestBuilder.build();
- OkHttpClient client = clientOptions.httpClient();
- if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
- client = clientOptions.httpClientWithTimeout(requestOptions);
- }
- if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
- okhttpRequest = okhttpRequest
- .newBuilder()
- .tag(
- RetryInterceptor.MaxRetriesOverride.class,
- new RetryInterceptor.MaxRetriesOverride(
- requestOptions.getMaxRetries().get()))
- .build();
- }
- CompletableFuture> future = new CompletableFuture<>();
- client.newCall(okhttpRequest).enqueue(new Callback() {
- @Override
- public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
- try (ResponseBody responseBody = response.body()) {
- String responseBodyString = responseBody != null ? responseBody.string() : "{}";
- if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsert200Response.class),
- response));
- return;
- }
- try {
- switch (response.code()) {
- case 400:
- future.completeExceptionally(new BadRequestError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- case 404:
- future.completeExceptionally(new NotFoundError(
- ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
- response));
- return;
- }
- } catch (JsonProcessingException ignored) {
- // unable to map error response, throwing generic error
- }
- Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
- future.completeExceptionally(new CloudPDFApiException(
- "Error with status code " + response.code(), response.code(), errorBody, response));
- return;
- } catch (JsonProcessingException e) {
- future.completeExceptionally(
- new CloudPDFException("Failed to deserialize response: " + e.getMessage(), e));
- } catch (IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- }
-
- @Override
- public void onFailure(@NotNull Call call, @NotNull IOException e) {
- future.completeExceptionally(new CloudPDFException("Network error executing HTTP request", e));
- }
- });
- return future;
- }
-
/**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
- public CompletableFuture> insertBlank(
+ public CompletableFuture> extract(
String docId, String layerName, Map body) {
- return insertBlank(
- docId, layerName, InsertBlankPagesRequest.builder().body(body).build());
+ return extract(
+ docId, layerName, ExtractPagesRequest.builder().body(body).build());
}
/**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
- public CompletableFuture> insertBlank(
+ public CompletableFuture> extract(
String docId, String layerName, Map body, RequestOptions requestOptions) {
- return insertBlank(
- docId, layerName, InsertBlankPagesRequest.builder().body(body).build(), requestOptions);
+ return extract(
+ docId, layerName, ExtractPagesRequest.builder().body(body).build(), requestOptions);
}
/**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
- public CompletableFuture> insertBlank(
- String docId, String layerName, InsertBlankPagesRequest request) {
- return insertBlank(docId, layerName, request, null);
+ public CompletableFuture> extract(
+ String docId, String layerName, ExtractPagesRequest request) {
+ return extract(docId, layerName, request, null);
}
/**
- * Body is {"size": {"width", "height"}, "count"?, "position"?} — size in PDF points, count in [1, 100], position a PagePosition (omitted → the end).
+ * A read, not a mutation: the source document is untouched and no event is published. Body is {"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}; the response body is the new PDF. With flatten the copy is the pages as they draw for usage ("print": a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes doc.download or doc.download.flattened, and paints only what the caller may read; includeAnnotations and includeFormFields choose what it paints, and are refused without flatten.
*/
- public CompletableFuture> insertBlank(
- String docId, String layerName, InsertBlankPagesRequest request, RequestOptions requestOptions) {
+ public CompletableFuture> extract(
+ String docId, String layerName, ExtractPagesRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v1/docs")
@@ -1091,7 +297,7 @@ public CompletableFuture {
httpUrl.addQueryParameter(_key, _value);
@@ -1114,10 +320,6 @@ public CompletableFuture> future =
- new CompletableFuture<>();
+ 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() : "{}";
+ try {
+ ResponseBody responseBody = response.body();
if (response.isSuccessful()) {
- future.complete(new CloudPDFClientHttpResponse<>(
- ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesInsertBlank200Response.class),
- response));
+ future.complete(
+ new CloudPDFClientHttpResponse<>(new ResponseBodyInputStream(response), response));
return;
}
+ String responseBodyString = responseBody != null ? responseBody.string() : "{}";
try {
switch (response.code()) {
case 400:
@@ -1182,25 +382,25 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
return future;
}
- public CompletableFuture> setName(
+ public CompletableFuture> flatten(
String docId, String layerName, Map body) {
- return setName(
- docId, layerName, SetNamePagesRequest.builder().body(body).build());
+ return flatten(
+ docId, layerName, FlattenPagesRequest.builder().body(body).build());
}
- public CompletableFuture> setName(
+ public CompletableFuture> flatten(
String docId, String layerName, Map body, RequestOptions requestOptions) {
- return setName(
- docId, layerName, SetNamePagesRequest.builder().body(body).build(), requestOptions);
+ return flatten(
+ docId, layerName, FlattenPagesRequest.builder().body(body).build(), requestOptions);
}
- public CompletableFuture> setName(
- String docId, String layerName, SetNamePagesRequest request) {
- return setName(docId, layerName, request, null);
+ public CompletableFuture> flatten(
+ String docId, String layerName, FlattenPagesRequest request) {
+ return flatten(docId, layerName, request, null);
}
- public CompletableFuture> setName(
- String docId, String layerName, SetNamePagesRequest request, RequestOptions requestOptions) {
+ public CompletableFuture> flatten(
+ String docId, String layerName, FlattenPagesRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v1/docs")
@@ -1208,7 +408,7 @@ public CompletableFuture>
.addPathSegments("layers")
.addPathSegment(layerName)
.addPathSegments("pages")
- .addPathSegments("names");
+ .addPathSegments("flatten");
if (requestOptions != null) {
requestOptions.getQueryParameters().forEach((_key, _value) -> {
httpUrl.addQueryParameter(_key, _value);
@@ -1249,7 +449,7 @@ public CompletableFuture>
requestOptions.getMaxRetries().get()))
.build();
}
- CompletableFuture> future = new CompletableFuture<>();
+ CompletableFuture> future = new CompletableFuture<>();
client.newCall(okhttpRequest).enqueue(new Callback() {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
@@ -1258,7 +458,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
if (response.isSuccessful()) {
future.complete(new CloudPDFClientHttpResponse<>(
ObjectMappers.JSON_MAPPER.readValue(
- responseBodyString, DocPagesSetName200Response.class),
+ responseBodyString, DocPagesFlatten200Response.class),
response));
return;
}
@@ -1298,129 +498,25 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
return future;
}
- public CompletableFuture> removeName(
+ public CompletableFuture