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 @@ -5,9 +5,9 @@
"generatorConfig": {
"moduleName": "CloudPDF"
},
"originGitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575",
"originGitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0.alpha.5",
"requestedVersion": "3.0.0.alpha.6",
"ciProvider": "github"
}
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "ruby",
"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
49 changes: 49 additions & 0 deletions lib/CloudPDF/documents/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,55 @@ def upload_proxy(request_options: {}, **params)
end
end

# 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).
#
# @param request_options [Hash]
# @param params [CloudPDF::Documents::Types::DocumentsImportFromRequest]
# @option request_options [String] :base_url
# @option request_options [Hash{String => Object}] :additional_headers
# @option request_options [Hash{String => Object}] :additional_query_parameters
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :tenant_id
#
# @example
# client.documents.import_from(tenant_id: "tenantId")
#
# @return [CloudPDF::Types::DocumentsImportFrom200Response]
def import_from(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
request_data = CloudPDF::Documents::Types::DocumentsImportFromRequest.new(params).to_h
non_body_param_names = %w[tenantId]
body = request_data.except(*non_body_param_names)

request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "POST",
path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/documents/import",
body: body,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
if code.between?(200, 299)
CloudPDF::Types::DocumentsImportFrom200Response.load(response.body)
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end

# @param request_options [Hash]
# @param params [CloudPDF::Documents::Types::DocumentsInitRequest]
# @option request_options [String] :base_url
Expand Down
25 changes: 25 additions & 0 deletions lib/CloudPDF/documents/types/documents_import_from_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
class DocumentsImportFromRequest < Internal::Types::Model
field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"

field :source, -> { CloudPDF::Documents::Types::DocumentsImportFromRequestSource }, optional: false, nullable: false

field :expected, -> { CloudPDF::Documents::Types::DocumentsImportFromRequestExpected }, optional: true, nullable: false

field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "idempotencyKey"

field :dedup_mode, -> { CloudPDF::Documents::Types::DocumentsImportFromRequestDedupMode }, optional: true, nullable: false, api_name: "dedupMode"

field :doc_id, -> { String }, optional: true, nullable: false, api_name: "docId"

field :mode, -> { CloudPDF::Documents::Types::DocumentsImportFromRequestMode }, optional: true, nullable: false
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
module DocumentsImportFromRequestDedupMode
extend CloudPDF::Internal::Types::Enum

ALWAYS_CREATE = "always-create"
REUSE_EXISTING = "reuse-existing"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
class DocumentsImportFromRequestExpected < Internal::Types::Model
field :size_bytes, -> { Integer }, optional: true, nullable: false, api_name: "sizeBytes"

field :sha256, -> { String }, optional: true, nullable: false
end
end
end
end
14 changes: 14 additions & 0 deletions lib/CloudPDF/documents/types/documents_import_from_request_mode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
module DocumentsImportFromRequestMode
extend CloudPDF::Internal::Types::Enum

SYNC = "sync"
ASYNC = "async"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
class DocumentsImportFromRequestSource < Internal::Types::Model
extend CloudPDF::Internal::Types::Union

discriminant :kind

member -> { CloudPDF::Documents::Types::DocumentsImportFromRequestSourceURL }, key: "URL"

member -> { CloudPDF::Documents::Types::DocumentsImportFromRequestSourceConnection }, key: "CONNECTION"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
class DocumentsImportFromRequestSourceConnection < Internal::Types::Model
field :connection_id, -> { String }, optional: false, nullable: false, api_name: "connectionId"

field :key, -> { String }, optional: false, nullable: false

field :revision, -> { String }, optional: true, nullable: false
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Documents
module Types
class DocumentsImportFromRequestSourceURL < Internal::Types::Model
field :url, -> { String }, optional: false, nullable: false
end
end
end
end
11 changes: 11 additions & 0 deletions lib/CloudPDF/types/documents_import_from200response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocumentsImportFrom200Response < Internal::Types::Model
field :tag, -> { CloudPDF::Types::DocumentsImportFrom200ResponseTag }, optional: false, nullable: false

field :document, -> { CloudPDF::Types::DocumentsImportFrom200ResponseDocument }, optional: false, nullable: false
end
end
end
33 changes: 33 additions & 0 deletions lib/CloudPDF/types/documents_import_from200response_document.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocumentsImportFrom200ResponseDocument < Internal::Types::Model
field :id, -> { String }, optional: false, nullable: false

field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"

field :state, -> { CloudPDF::Types::DocumentsImportFrom200ResponseDocumentState }, optional: false, nullable: false

field :base_sha, -> { String }, optional: false, nullable: true, api_name: "baseSha"

field :storage_size_bytes, -> { Integer }, optional: false, nullable: true, api_name: "storageSizeBytes"

field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: true

field :idempotency_key, -> { String }, optional: false, nullable: true, api_name: "idempotencyKey"

field :failure_reason, -> { String }, optional: false, nullable: true, api_name: "failureReason"

field :thumbnail_state, -> { CloudPDF::Types::DocumentsImportFrom200ResponseDocumentThumbnailState }, optional: true, nullable: false, api_name: "thumbnailState"

field :thumbnail_url, -> { String }, optional: true, nullable: false, api_name: "thumbnailUrl"

field :created_at, -> { Integer }, optional: false, nullable: false, api_name: "createdAt"

field :updated_at, -> { Integer }, optional: false, nullable: false, api_name: "updatedAt"

field :created_by, -> { String }, optional: false, nullable: true, api_name: "createdBy"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom200ResponseDocumentState
extend CloudPDF::Internal::Types::Enum

PENDING = "pending"
READY = "ready"
FAILED = "failed"
DELETING = "deleting"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom200ResponseDocumentThumbnailState
extend CloudPDF::Internal::Types::Enum

PENDING = "pending"
READY = "ready"
LOCKED = "locked"
FAILED = "failed"
end
end
end
13 changes: 13 additions & 0 deletions lib/CloudPDF/types/documents_import_from200response_tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom200ResponseTag
extend CloudPDF::Internal::Types::Enum

IMPORTED = "imported"
DEDUPED = "deduped"
ACCEPTED = "accepted"
end
end
end
11 changes: 11 additions & 0 deletions lib/CloudPDF/types/documents_import_from202response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocumentsImportFrom202Response < Internal::Types::Model
field :tag, -> { CloudPDF::Types::DocumentsImportFrom202ResponseTag }, optional: false, nullable: false

field :document, -> { CloudPDF::Types::DocumentsImportFrom202ResponseDocument }, optional: false, nullable: false
end
end
end
33 changes: 33 additions & 0 deletions lib/CloudPDF/types/documents_import_from202response_document.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocumentsImportFrom202ResponseDocument < Internal::Types::Model
field :id, -> { String }, optional: false, nullable: false

field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"

field :state, -> { CloudPDF::Types::DocumentsImportFrom202ResponseDocumentState }, optional: false, nullable: false

field :base_sha, -> { String }, optional: false, nullable: true, api_name: "baseSha"

field :storage_size_bytes, -> { Integer }, optional: false, nullable: true, api_name: "storageSizeBytes"

field :metadata, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: true

field :idempotency_key, -> { String }, optional: false, nullable: true, api_name: "idempotencyKey"

field :failure_reason, -> { String }, optional: false, nullable: true, api_name: "failureReason"

field :thumbnail_state, -> { CloudPDF::Types::DocumentsImportFrom202ResponseDocumentThumbnailState }, optional: true, nullable: false, api_name: "thumbnailState"

field :thumbnail_url, -> { String }, optional: true, nullable: false, api_name: "thumbnailUrl"

field :created_at, -> { Integer }, optional: false, nullable: false, api_name: "createdAt"

field :updated_at, -> { Integer }, optional: false, nullable: false, api_name: "updatedAt"

field :created_by, -> { String }, optional: false, nullable: true, api_name: "createdBy"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom202ResponseDocumentState
extend CloudPDF::Internal::Types::Enum

PENDING = "pending"
READY = "ready"
FAILED = "failed"
DELETING = "deleting"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom202ResponseDocumentThumbnailState
extend CloudPDF::Internal::Types::Enum

PENDING = "pending"
READY = "ready"
LOCKED = "locked"
FAILED = "failed"
end
end
end
13 changes: 13 additions & 0 deletions lib/CloudPDF/types/documents_import_from202response_tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocumentsImportFrom202ResponseTag
extend CloudPDF::Internal::Types::Enum

IMPORTED = "imported"
DEDUPED = "deduped"
ACCEPTED = "accepted"
end
end
end
9 changes: 9 additions & 0 deletions lib/CloudPDF/types/documents_import_from400response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocumentsImportFrom400Response < Internal::Types::Model
field :error, -> { CloudPDF::Types::DocumentsImportFrom400ResponseError }, optional: false, nullable: false
end
end
end
Loading
Loading