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
6 changes: 3 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"homepage": "https://www.cloudpdf.com"
}
},
"originGitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575",
"originGitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-alpha.5",
"requestedVersion": "3.0.0-alpha.6",
"ciProvider": "github",
"sdkVersion": "3.0.0-alpha.5"
"sdkVersion": "3.0.0-alpha.6"
}
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "php",
"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
117 changes: 117 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,123 @@ $client->documents->uploadProxy(
</dl>


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

<details><summary><code>$client-&gt;documents-&gt;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>

```php
$client->documents->importFrom(
'tenantId',
new DocumentsImportFromRequest([
'source' => DocumentsImportFromRequestSource::url(new DocumentsImportFromRequestSourceUrl([
'url' => 'url',
])),
]),
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**$tenantId:** `string`

</dd>
</dl>

<dl>
<dd>

**$source:** `DocumentsImportFromRequestSource`

</dd>
</dl>

<dl>
<dd>

**$expected:** `?DocumentsImportFromRequestExpected`

</dd>
</dl>

<dl>
<dd>

**$metadata:** `?array`

</dd>
</dl>

<dl>
<dd>

**$idempotencyKey:** `?string`

</dd>
</dl>

<dl>
<dd>

**$dedupMode:** `?string`

</dd>
</dl>

<dl>
<dd>

**$docId:** `?string`

</dd>
</dl>

<dl>
<dd>

**$mode:** `?string`

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


</dd>
</dl>
</details>
Expand Down
4 changes: 2 additions & 2 deletions src/CloudPDFClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public function __construct(
$defaultHeaders = [
'X-Fern-Language' => 'PHP',
'X-Fern-SDK-Name' => 'CloudPDF',
'X-Fern-SDK-Version' => '3.0.0-alpha.5',
'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.5',
'X-Fern-SDK-Version' => '3.0.0-alpha.6',
'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.6',
];
if ($token != null) {
$defaultHeaders['Authorization'] = "Bearer $token";
Expand Down
64 changes: 64 additions & 0 deletions src/Documents/DocumentsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use CloudPDF\Types\DocumentsUploadProxy200Response;
use CloudPDF\Core\Multipart\MultipartFormData;
use CloudPDF\Core\Multipart\MultipartApiRequest;
use CloudPDF\Documents\Requests\DocumentsImportFromRequest;
use CloudPDF\Types\DocumentsImportFrom200Response;
use CloudPDF\Documents\Requests\DocumentsInitRequest;
use CloudPDF\Types\DocumentsInit200Response;

Expand Down Expand Up @@ -448,6 +450,68 @@ public function uploadProxy(string $tenantId, string $id, UploadProxyDocumentsRe
);
}

/**
* 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).
*
* Example:
* ```php
* $client->documents->importFrom(
* 'tenantId',
* new DocumentsImportFromRequest([
* 'source' => DocumentsImportFromRequestSource::url(new DocumentsImportFromRequestSourceUrl([
* 'url' => 'url',
* ])),
* ]),
* );
* ```
*
* @param string $tenantId
* @param DocumentsImportFromRequest $request
* @param ?array{
* baseUrl?: string,
* maxRetries?: int,
* timeout?: float,
* headers?: array<string, string>,
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return ?DocumentsImportFrom200Response
* @throws CloudPDFException
* @throws CloudPDFApiException
*/
public function importFrom(string $tenantId, DocumentsImportFromRequest $request, ?array $options = null): ?DocumentsImportFrom200Response
{
$options = array_merge($this->options, $options ?? []);
try {
$response = $this->client->sendRequest(
new JsonApiRequest(
baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '',
path: "v1/tenants/{$tenantId}/documents/import",
method: HttpMethod::POST,
body: $request,
),
$options,
);
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return DocumentsImportFrom200Response::fromJson($json);
}
} catch (JsonException $e) {
throw new CloudPDFException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e);
} catch (ClientExceptionInterface $e) {
throw new CloudPDFException(message: $e->getMessage(), previous: $e);
}
throw new CloudPDFApiException(
message: 'API request failed',
statusCode: $statusCode,
body: $response->getBody()->getContents(),
);
}

/**
* Example:
* ```php
Expand Down
79 changes: 79 additions & 0 deletions src/Documents/Requests/DocumentsImportFromRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace CloudPDF\Documents\Requests;

use CloudPDF\Core\Json\JsonSerializableType;
use CloudPDF\Documents\Types\DocumentsImportFromRequestSource;
use CloudPDF\Core\Json\JsonProperty;
use CloudPDF\Documents\Types\DocumentsImportFromRequestExpected;
use CloudPDF\Core\Types\ArrayType;
use CloudPDF\Documents\Types\DocumentsImportFromRequestDedupMode;
use CloudPDF\Documents\Types\DocumentsImportFromRequestMode;

class DocumentsImportFromRequest extends JsonSerializableType
{
/**
* @var DocumentsImportFromRequestSource $source
*/
#[JsonProperty('source')]
public DocumentsImportFromRequestSource $source;

/**
* @var ?DocumentsImportFromRequestExpected $expected
*/
#[JsonProperty('expected')]
public ?DocumentsImportFromRequestExpected $expected;

/**
* @var ?array<string, mixed> $metadata
*/
#[JsonProperty('metadata'), ArrayType(['string' => 'mixed'])]
public ?array $metadata;

/**
* @var ?string $idempotencyKey
*/
#[JsonProperty('idempotencyKey')]
public ?string $idempotencyKey;

/**
* @var ?value-of<DocumentsImportFromRequestDedupMode> $dedupMode
*/
#[JsonProperty('dedupMode')]
public ?string $dedupMode;

/**
* @var ?string $docId
*/
#[JsonProperty('docId')]
public ?string $docId;

/**
* @var ?value-of<DocumentsImportFromRequestMode> $mode
*/
#[JsonProperty('mode')]
public ?string $mode;

/**
* @param array{
* source: DocumentsImportFromRequestSource,
* expected?: ?DocumentsImportFromRequestExpected,
* metadata?: ?array<string, mixed>,
* idempotencyKey?: ?string,
* dedupMode?: ?value-of<DocumentsImportFromRequestDedupMode>,
* docId?: ?string,
* mode?: ?value-of<DocumentsImportFromRequestMode>,
* } $values
*/
public function __construct(
array $values,
) {
$this->source = $values['source'];
$this->expected = $values['expected'] ?? null;
$this->metadata = $values['metadata'] ?? null;
$this->idempotencyKey = $values['idempotencyKey'] ?? null;
$this->dedupMode = $values['dedupMode'] ?? null;
$this->docId = $values['docId'] ?? null;
$this->mode = $values['mode'] ?? null;
}
}
9 changes: 9 additions & 0 deletions src/Documents/Types/DocumentsImportFromRequestDedupMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace CloudPDF\Documents\Types;

enum DocumentsImportFromRequestDedupMode: string
{
case AlwaysCreate = "always-create";
case ReuseExisting = "reuse-existing";
}
42 changes: 42 additions & 0 deletions src/Documents/Types/DocumentsImportFromRequestExpected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace CloudPDF\Documents\Types;

use CloudPDF\Core\Json\JsonSerializableType;
use CloudPDF\Core\Json\JsonProperty;

class DocumentsImportFromRequestExpected extends JsonSerializableType
{
/**
* @var ?int $sizeBytes
*/
#[JsonProperty('sizeBytes')]
public ?int $sizeBytes;

/**
* @var ?string $sha256
*/
#[JsonProperty('sha256')]
public ?string $sha256;

/**
* @param array{
* sizeBytes?: ?int,
* sha256?: ?string,
* } $values
*/
public function __construct(
array $values = [],
) {
$this->sizeBytes = $values['sizeBytes'] ?? null;
$this->sha256 = $values['sha256'] ?? null;
}

/**
* @return string
*/
public function __toString(): string
{
return $this->toJson();
}
}
9 changes: 9 additions & 0 deletions src/Documents/Types/DocumentsImportFromRequestMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace CloudPDF\Documents\Types;

enum DocumentsImportFromRequestMode: string
{
case Sync = "sync";
case Async = "async";
}
Loading
Loading