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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 6 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"generatorVersion": "4.17.0",
"generatorConfig": {
"group": "com.cloudpdf",
"artifact": "cloudpdf",
"package-prefix": "com.cloudpdf.api"
"artifact": "sdk",
"package-prefix": "com.cloudpdf",
"client-class-name": "CloudPDFClient",
"base-exception-class-name": "CloudPDFException",
"base-api-exception-class-name": "CloudPDFApiException"
},
"originGitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"originGitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-alpha.1",
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Cloudpdf Java Library
# CloudPDF Java SDK

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Cloudpdf%2FJava)

The Cloudpdf Java library provides convenient access to the Cloudpdf APIs from Java.
The official Java SDK for the CloudPDF API.

## Table of Contents

Expand All @@ -29,12 +29,12 @@ Instantiate and use the client with the following:
```java
package com.example.usage;

import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.api.resources.tenants.requests.TenantsCreateRequest;
import com.cloudpdf.CloudPDFClient;
import com.cloudpdf.resources.tenants.requests.TenantsCreateRequest;

public class Example {
public static void main(String[] args) {
CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.token("<token>")
.build();
Expand All @@ -54,9 +54,9 @@ public class Example {
You can set a custom base URL when constructing the client.

```java
import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.CloudPDFClient;

CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.url("https://example.com")
.build();
Expand All @@ -67,11 +67,11 @@ CloudpdfApiClient client = CloudpdfApiClient
When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown.

```java
import com.cloudpdf.api.core.CloudpdfApiApiException;
import com.cloudpdf.core.CloudPDFApiException;

try{
client.tenants().create(...);
} catch (CloudpdfApiApiException e){
} catch (CloudPDFApiException e){
// Do something with the API exception...
}
```
Expand All @@ -84,12 +84,12 @@ This SDK is built to work with any instance of `OkHttpClient`. By default, if no
However, you can pass your own client like so:

```java
import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.CloudPDFClient;
import okhttp3.OkHttpClient;

OkHttpClient customClient = ...;

CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.httpClient(customClient)
.build();
Expand Down Expand Up @@ -120,9 +120,9 @@ Which status codes are retried depends on the `retry-status-codes` generator con
Use the `maxRetries` client option to configure this behavior.

```java
import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.CloudPDFClient;

CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.maxRetries(1)
.build();
Expand All @@ -132,11 +132,11 @@ CloudpdfApiClient client = CloudpdfApiClient

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
```java
import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.CloudPDFClient;
import com.cloudpdf.core.RequestOptions;

// Client level
CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.timeout(60)
.build();
Expand All @@ -156,11 +156,11 @@ client.tenants().create(
The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level.

```java
import com.cloudpdf.api.CloudpdfApiClient;
import com.cloudpdf.api.core.RequestOptions;
import com.cloudpdf.CloudPDFClient;
import com.cloudpdf.core.RequestOptions;

// Client level
CloudpdfApiClient client = CloudpdfApiClient
CloudPDFClient client = CloudPDFClient
.builder()
.addHeader("X-Custom-Header", "custom-value")
.addHeader("X-Request-Id", "abc-123")
Expand All @@ -184,7 +184,7 @@ The `withRawResponse()` method returns a raw client that wraps all responses wit
(A normal client's `response` is identical to a raw client's `response.body()`.)

```java
CloudpdfApiHttpResponse response = client.tenants().withRawResponse().create(...);
CloudPDFClientHttpResponse response = client.tenants().withRawResponse().create(...);

System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ version = '3.0.0-alpha.1'

jar {
dependsOn(":generatePomFileForMavenPublication")
archiveBaseName = "cloudpdf"
archiveBaseName = "sdk"
}

sourcesJar {
archiveBaseName = "cloudpdf"
archiveBaseName = "sdk"
}

javadocJar {
archiveBaseName = "cloudpdf"
archiveBaseName = "sdk"
}

test {
Expand All @@ -71,7 +71,7 @@ publishing {
publications {
maven(MavenPublication) {
groupId = 'com.cloudpdf'
artifactId = 'cloudpdf'
artifactId = 'sdk'
version = '3.0.0-alpha.1'
from components.java
pom {
Expand Down
2 changes: 1 addition & 1 deletion cloudpdf-generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "6858ce7912e9063d8fb171ade95fc473db01c5971a3af241a612dda79cc05100",
"gitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"gitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

public final class App {
public static void main(String[] args) {
// import com.cloudpdf.api.AsyncCloudpdfApiClient
// import com.cloudpdf.api.AsyncCloudPDFClient
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = 'cloudpdf'
rootProject.name = 'sdk'

include 'sample-app'
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.cloudpdf.api.resources.tokens.AsyncTokensClient;
import java.util.function.Supplier;

public class AsyncCloudpdfApiClient {
public class AsyncCloudPDFClient {
protected final ClientOptions clientOptions;

protected final Supplier<AsyncDeploymentClient> deploymentClient;
Expand All @@ -25,7 +25,7 @@ public class AsyncCloudpdfApiClient {

protected final Supplier<AsyncTokensClient> tokensClient;

public AsyncCloudpdfApiClient(ClientOptions clientOptions) {
public AsyncCloudPDFClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.deploymentClient = Suppliers.memoize(() -> new AsyncDeploymentClient(clientOptions));
this.docClient = Suppliers.memoize(() -> new AsyncDocClient(clientOptions));
Expand Down Expand Up @@ -54,7 +54,7 @@ public AsyncTokensClient tokens() {
return this.tokensClient.get();
}

public static AsyncCloudpdfApiClientBuilder builder() {
return new AsyncCloudpdfApiClientBuilder();
public static AsyncCloudPDFClientBuilder builder() {
return new AsyncCloudPDFClientBuilder();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Optional;
import okhttp3.OkHttpClient;

public class AsyncCloudpdfApiClientBuilder {
public class AsyncCloudPDFClientBuilder {
private Optional<Integer> timeout = Optional.empty();

private Optional<Integer> maxRetries = Optional.empty();
Expand All @@ -35,68 +35,68 @@ public class AsyncCloudpdfApiClientBuilder {
/**
* Sets token
*/
public AsyncCloudpdfApiClientBuilder token(String token) {
public AsyncCloudPDFClientBuilder token(String token) {
this.token = token;
return this;
}

public AsyncCloudpdfApiClientBuilder url(String url) {
public AsyncCloudPDFClientBuilder url(String url) {
this.environment = Environment.custom(url);
return this;
}

/**
* Sets the timeout (in seconds) for the client. Defaults to 60 seconds.
*/
public AsyncCloudpdfApiClientBuilder timeout(int timeout) {
public AsyncCloudPDFClientBuilder timeout(int timeout) {
this.timeout = Optional.of(timeout);
return this;
}

/**
* Sets the maximum number of retries for the client. Defaults to 2 retries.
*/
public AsyncCloudpdfApiClientBuilder maxRetries(int maxRetries) {
public AsyncCloudPDFClientBuilder maxRetries(int maxRetries) {
this.maxRetries = Optional.of(maxRetries);
return this;
}

/**
* Sets the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds.
*/
public AsyncCloudpdfApiClientBuilder initialRetryDelayMillis(long initialRetryDelayMillis) {
public AsyncCloudPDFClientBuilder initialRetryDelayMillis(long initialRetryDelayMillis) {
this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis);
return this;
}

/**
* Sets the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds.
*/
public AsyncCloudpdfApiClientBuilder maxRetryDelayMillis(long maxRetryDelayMillis) {
public AsyncCloudPDFClientBuilder maxRetryDelayMillis(long maxRetryDelayMillis) {
this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis);
return this;
}

/**
* Sets the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2.
*/
public AsyncCloudpdfApiClientBuilder retryJitterFactor(double retryJitterFactor) {
public AsyncCloudPDFClientBuilder retryJitterFactor(double retryJitterFactor) {
this.retryJitterFactor = Optional.of(retryJitterFactor);
return this;
}

/**
* Sets the underlying OkHttp client
*/
public AsyncCloudpdfApiClientBuilder httpClient(OkHttpClient httpClient) {
public AsyncCloudPDFClientBuilder httpClient(OkHttpClient httpClient) {
this.httpClient = httpClient;
return this;
}

/**
* Configure logging for the SDK. Silent by default — no log output unless explicitly configured.
*/
public AsyncCloudpdfApiClientBuilder logging(LogConfig logging) {
public AsyncCloudPDFClientBuilder logging(LogConfig logging) {
this.logging = Optional.of(logging);
return this;
}
Expand All @@ -109,7 +109,7 @@ public AsyncCloudpdfApiClientBuilder logging(LogConfig logging) {
* @param value The header value
* @return This builder for method chaining
*/
public AsyncCloudpdfApiClientBuilder addHeader(String name, String value) {
public AsyncCloudPDFClientBuilder addHeader(String name, String value) {
this.customHeaders.put(name, value);
return this;
}
Expand Down Expand Up @@ -253,11 +253,11 @@ protected void setAdditional(ClientOptions.Builder builder) {}
*/
protected void validateConfiguration() {}

public AsyncCloudpdfApiClient build() {
public AsyncCloudPDFClient build() {
if (token == null) {
throw new RuntimeException("Please provide token");
}
validateConfiguration();
return new AsyncCloudpdfApiClient(buildClientOptions());
return new AsyncCloudPDFClient(buildClientOptions());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.cloudpdf.api.resources.tokens.TokensClient;
import java.util.function.Supplier;

public class CloudpdfApiClient {
public class CloudPDFClient {
protected final ClientOptions clientOptions;

protected final Supplier<DeploymentClient> deploymentClient;
Expand All @@ -25,7 +25,7 @@ public class CloudpdfApiClient {

protected final Supplier<TokensClient> tokensClient;

public CloudpdfApiClient(ClientOptions clientOptions) {
public CloudPDFClient(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
this.deploymentClient = Suppliers.memoize(() -> new DeploymentClient(clientOptions));
this.docClient = Suppliers.memoize(() -> new DocClient(clientOptions));
Expand Down Expand Up @@ -54,7 +54,7 @@ public TokensClient tokens() {
return this.tokensClient.get();
}

public static CloudpdfApiClientBuilder builder() {
return new CloudpdfApiClientBuilder();
public static CloudPDFClientBuilder builder() {
return new CloudPDFClientBuilder();
}
}
Loading
Loading