Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"base-exception-class-name": "CloudPDFException",
"base-api-exception-class-name": "CloudPDFApiException"
},
"originGitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575",
"originGitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-alpha.5",
"requestedVersion": "3.0.0-alpha.6",
"ciProvider": "github"
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ java {

group = 'com.cloudpdf'

version = '3.0.0-alpha.5'
version = '3.0.0-alpha.6'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand All @@ -73,7 +73,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cloudpdf'
artifactId = 'sdk'
version = '3.0.0-alpha.5'
version = '3.0.0-alpha.6'
from components.java
pom {
name = 'CloudPDF'
Expand Down
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "java",
"canonicalVersion": "3.0.0-next.5",
"sdkVersion": "3.0.0-alpha.5",
"canonicalVersion": "3.0.0-next.6",
"sdkVersion": "3.0.0-alpha.6",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "e86b3f1766a77c28cb782a6513b5a86998668cd4e688e5b5ac27342e58637cd7",
"gitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575",
"openapiSha256": "b3e236a932673e27e05825352e1bc3675369d7505040bf7d7760e542aae8d38d",
"gitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
123 changes: 123 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,129 @@ client.documents().uploadProxy(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.documents.importFrom(tenantId, request) -> DocumentsImportFrom200Response</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```java
client.documents().importFrom(
"tenantId",
DocumentsImportFromRequest
.builder()
.source(
DocumentsImportFromRequestSource.url(
DocumentsImportFromRequestSourceUrl
.builder()
.url("url")
.build()
)
)
.build()
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**tenantId:** `String`

</dd>
</dl>

<dl>
<dd>

**source:** `DocumentsImportFromRequestSource`

</dd>
</dl>

<dl>
<dd>

**expected:** `Optional<DocumentsImportFromRequestExpected>`

</dd>
</dl>

<dl>
<dd>

**metadata:** `Optional<Map<String, Object>>`

</dd>
</dl>

<dl>
<dd>

**idempotencyKey:** `Optional<String>`

</dd>
</dl>

<dl>
<dd>

**dedupMode:** `Optional<DocumentsImportFromRequestDedupMode>`

</dd>
</dl>

<dl>
<dd>

**docId:** `Optional<String>`

</dd>
</dl>

<dl>
<dd>

**mode:** `Optional<DocumentsImportFromRequestMode>`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.5");
put("X-Fern-SDK-Version", "3.0.0-alpha.6");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/api/errors/BadGatewayError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.cloudpdf.api.errors;

import com.cloudpdf.api.core.CloudPDFApiException;
import com.cloudpdf.api.types.DocumentsImportFrom502Response;
import okhttp3.Response;

public final class BadGatewayError extends CloudPDFApiException {
/**
* The body of the response that triggered the exception.
*/
private final DocumentsImportFrom502Response body;

public BadGatewayError(DocumentsImportFrom502Response body) {
super("BadGatewayError", 502, body);
this.body = body;
}

public BadGatewayError(DocumentsImportFrom502Response body, Response rawResponse) {
super("BadGatewayError", 502, body, rawResponse);
this.body = body;
}

/**
* @return the body
*/
@java.lang.Override
public DocumentsImportFrom502Response body() {
return this.body;
}
}
18 changes: 18 additions & 0 deletions src/main/java/api/resources/documents/AsyncDocumentsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.api.resources.documents.requests.DeleteDocumentsRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsCommitRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsImportFromRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsInitRequest;
import com.cloudpdf.api.resources.documents.requests.DownloadDocumentsRequest;
import com.cloudpdf.api.resources.documents.requests.GetDocumentsRequest;
Expand All @@ -15,6 +16,7 @@
import com.cloudpdf.api.resources.documents.requests.UploadProxyDocumentsRequest;
import com.cloudpdf.api.types.DocumentsCommit200Response;
import com.cloudpdf.api.types.DocumentsGet200Response;
import com.cloudpdf.api.types.DocumentsImportFrom200Response;
import com.cloudpdf.api.types.DocumentsInit200Response;
import com.cloudpdf.api.types.DocumentsList200Response;
import com.cloudpdf.api.types.DocumentsUploadProxy200Response;
Expand Down Expand Up @@ -184,6 +186,22 @@ public CompletableFuture<DocumentsUploadProxy200Response> uploadProxy(
.thenApply(response -> response.body());
}

/**
* Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); <code>revision</code> is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
*/
public CompletableFuture<DocumentsImportFrom200Response> importFrom(
String tenantId, DocumentsImportFromRequest request) {
return this.rawClient.importFrom(tenantId, request).thenApply(response -> response.body());
}

/**
* Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); <code>revision</code> is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
*/
public CompletableFuture<DocumentsImportFrom200Response> importFrom(
String tenantId, DocumentsImportFromRequest request, RequestOptions requestOptions) {
return this.rawClient.importFrom(tenantId, request, requestOptions).thenApply(response -> response.body());
}

public CompletableFuture<DocumentsInit200Response> init(String tenantId, DocumentsInitRequest request) {
return this.rawClient.init(tenantId, request).thenApply(response -> response.body());
}
Expand Down
111 changes: 111 additions & 0 deletions src/main/java/api/resources/documents/AsyncRawDocumentsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.api.core.ResponseBodyInputStream;
import com.cloudpdf.api.core.RetryInterceptor;
import com.cloudpdf.api.errors.BadGatewayError;
import com.cloudpdf.api.errors.BadRequestError;
import com.cloudpdf.api.errors.ConflictError;
import com.cloudpdf.api.errors.ForbiddenError;
import com.cloudpdf.api.errors.NotFoundError;
import com.cloudpdf.api.resources.documents.requests.DeleteDocumentsRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsCommitRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsImportFromRequest;
import com.cloudpdf.api.resources.documents.requests.DocumentsInitRequest;
import com.cloudpdf.api.resources.documents.requests.DownloadDocumentsRequest;
import com.cloudpdf.api.resources.documents.requests.GetDocumentsRequest;
Expand All @@ -28,6 +30,8 @@
import com.cloudpdf.api.resources.documents.requests.UploadProxyDocumentsRequest;
import com.cloudpdf.api.types.DocumentsCommit200Response;
import com.cloudpdf.api.types.DocumentsGet200Response;
import com.cloudpdf.api.types.DocumentsImportFrom200Response;
import com.cloudpdf.api.types.DocumentsImportFrom502Response;
import com.cloudpdf.api.types.DocumentsInit200Response;
import com.cloudpdf.api.types.DocumentsList200Response;
import com.cloudpdf.api.types.DocumentsUploadProxy200Response;
Expand Down Expand Up @@ -1043,6 +1047,113 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
return future;
}

/**
* Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); <code>revision</code> is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
*/
public CompletableFuture<CloudPDFClientHttpResponse<DocumentsImportFrom200Response>> importFrom(
String tenantId, DocumentsImportFromRequest request) {
return importFrom(tenantId, request, null);
}

/**
* Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); <code>revision</code> is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
*/
public CompletableFuture<CloudPDFClientHttpResponse<DocumentsImportFrom200Response>> importFrom(
String tenantId, DocumentsImportFromRequest request, RequestOptions requestOptions) {
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
.newBuilder()
.addPathSegments("v1/tenants")
.addPathSegment(tenantId)
.addPathSegments("documents")
.addPathSegments("import");
if (requestOptions != null) {
requestOptions.getQueryParameters().forEach((_key, _value) -> {
httpUrl.addQueryParameter(_key, _value);
});
}
RequestBody body;
try {
body = RequestBody.create(
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
} catch (JsonProcessingException e) {
throw new CloudPDFException("Failed to serialize request", e);
}
Request okhttpRequest = new Request.Builder()
.url(httpUrl.build())
.method("POST", body)
.headers(Headers.of(clientOptions.headers(requestOptions)))
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
OkHttpClient client = clientOptions.httpClient();
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
client = clientOptions.httpClientWithTimeout(requestOptions);
}
if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
okhttpRequest = okhttpRequest
.newBuilder()
.tag(
RetryInterceptor.MaxRetriesOverride.class,
new RetryInterceptor.MaxRetriesOverride(
requestOptions.getMaxRetries().get()))
.build();
}
CompletableFuture<CloudPDFClientHttpResponse<DocumentsImportFrom200Response>> 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, DocumentsImportFrom200Response.class),
response));
return;
}
try {
switch (response.code()) {
case 400:
future.completeExceptionally(new BadRequestError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 403:
future.completeExceptionally(new ForbiddenError(
ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class),
response));
return;
case 502:
future.completeExceptionally(new BadGatewayError(
ObjectMappers.JSON_MAPPER.readValue(
responseBodyString, DocumentsImportFrom502Response.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<CloudPDFClientHttpResponse<DocumentsInit200Response>> init(
String tenantId, DocumentsInitRequest request) {
return init(tenantId, request, null);
Expand Down
Loading
Loading