تخطَّ إلى المستندات
Ruby

client.imports

كل دالّة في مساحة الأسماء هذه: توقيعها ومعلماتها وما تُرجعه ومثال عليها.

الدوالّ

Bring an old mailbox across from a Google Takeout, .mbox, .eml, .zip or .tgz export, with progress and a list of what did not come through.

imports.list

List one page of mailbox imports

الصلاحياتthreads:readيتصفح النتائج صفحةً صفحة
التوقيع
list(address_id: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of the imports in the workspace, newest first. Nothing is dropped from the history, so following next_cursor while has_more? is true reaches the very first import, and list_all and iterate do that walk for you. Each carries its status, the bytes read so far out of the total, and running counts of messages seen, imported, skipped as duplicates, left out by your options and not imported.

A key limited to particular addresses sees only imports into those addresses.

المعلمات

address_idString

Only imports into this address.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, an import id. One that names no import this key can see is a 400 invalid_cursor.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of import Hashes, with items, has_more? and next_cursor.

مثال

page = client.imports.list(limit: 50) page.items.each do |item|  puts "#{item[:address]} #{item[:status]} #{item[:counts][:imported]}"end

ملاحظات

  • A GET is retried automatically on network failure and on 408, 429 and 5xx responses, up to the client's max_retries.

متاح أيضًا في

API
GET /imports
TypeScript
imports.list()
Python
imports.list()
CLI
openemail imports list

imports.list_all

Collect every mailbox import into one array

الصلاحياتthreads:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all(address_id: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Follows next_cursor from page to page and returns every import in the workspace, newest first, narrowed to one address when address_id: is given. A key limited to particular addresses sees only imports into those addresses.

المعلمات

address_idString

Only imports into this address.

limitInteger

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorString

An import id to start after, skipping everything newer.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of import Hashes holding every import across all pages.

مثال

imports = client.imports.list_all failed = imports.select { |item| item[:status] == "failed" } puts "#{failed.length} of #{imports.length} imports failed"

ملاحظات

  • A failure on any page raises out of the whole call, and none of the pages already read are returned.

متاح أيضًا في

API
GET /imports
TypeScript
imports.listAll()
Python
imports.list_all()

imports.iterate

Stream mailbox imports one at a time

الصلاحياتthreads:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate(address_id: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

Returns an Enumerator that yields imports individually, newest first, or yields each one to a block when given one, and requests the next page only once the current one is drained. Breaking out of the loop stops the requests.

المعلمات

address_idString

Only imports into this address.

limitInteger

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorString

An import id to start after, skipping everything newer.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of import Hashes (or yields each one to a block), one import per step.

مثال

running = client.imports.iterate(address_id: "addr_2b7e").find { |item| item[:status] == "running" } puts running[:id], running[:counts][:imported] if running

ملاحظات

  • The Enumerator is lazy, so an abandoned loop costs only the pages you consumed.

متاح أيضًا في

API
GET /imports
TypeScript
imports.iterate()
Python
imports.iterate()

imports.get

Read one mailbox import

الصلاحياتthreads:read
التوقيع
get(id, api_key: nil) -> Hash

Returns one import with its status, byte progress and counts. Poll it while status is queued or running; it settles on completed, failed or cancelled.

An id from another workspace answers exactly like one that never existed, with 404.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with id, addressId, address, status, options, files, formats, chunkBytes, totalBytes, processedBytes, counts, labelsCreated, labelsSkipped, lastError, uploadDeleted, createdAt, startedAt and finishedAt. counts holds seen, imported, duplicate, filtered, failed and threads.

مثال

item = client.imports.get("imp_3f9c2a7b1e4d8f60a5c7b92d") puts "#{item[:status]} #{item[:processedBytes]} / #{item[:totalBytes]}"

ملاحظات

  • lastError is set only when status is failed.

متاح أيضًا في

API
GET /imports/{id}
TypeScript
imports.get()
Python
imports.get()
CLI
openemail imports get

imports.create

Create a mailbox import and get its upload plan

الصلاحياتthreads:write
التوقيع
create(body = nil, api_key: nil, **fields) -> Hash

Creates an import into one address of the workspace and returns it with status set to uploading. Each file is uploaded in parts of chunkBytes, files[i][:chunks] of them, through upload_chunk, and start then queues the import.

The import reads Google Takeout archives, .mbox files from Apple Mail, Thunderbird and most desktop apps, .eml files, and .zip or .tgz archives holding any of those, up to 100 GB a file and 50 files an import. Threads, dates and labels come across. Imported mail is quiet: it runs no rules, forwards, notifications, summaries or webhooks.

import_files does create, upload and start in one call.

المعلمات

addressIdStringمطلوب

The address the mail belongs to. It must be an address this workspace owns and this key may act for.

filesArray<Hash>مطلوب

Each file as a Hash with name and bytes, its size, 1 to 50 of them, each at most 100 GB.

options.keepInboxBoolean

Default true: mail that was in the old inbox lands in Inbox with its unread state. False files everything under Archive. It goes inside the options Hash, as do the next two.

options.includeSpamBoolean

Default false.

options.includeTrashBoolean

Default false.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash for the import, shaped like the one get returns, with status set to uploading, chunkBytes and each file's chunks.

مثال

item = client.imports.create(  addressId: "addr_2b7e",  files: [{name: "takeout-001.zip", bytes: 2_147_483_648}],  options: {keepInbox: true, includeSpam: false}) puts item[:chunkBytes], item[:files][0][:chunks]

ملاحظات

  • An address with an import already queued or running is 409 already_running.

  • Not retried automatically.

متاح أيضًا في

API
POST /imports
TypeScript
imports.create()
Python
imports.create()
CLI
openemail imports create

imports.upload_state

See which parts of the upload have arrived

الصلاحياتthreads:write
التوقيع
upload_state(id, api_key: nil) -> Hash

For each file, the indexes of the parts already stored, so an interrupted upload sends only what is missing. Empty once the import has left the uploading state.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with id, status and received, one sorted Array of part indexes per file.

مثال

state = client.imports.upload_state("imp_3f9c2a7b1e4d8f60a5c7b92d") puts state[:received][0].length

متاح أيضًا في

API
GET /imports/{id}/upload
TypeScript
imports.uploadState()
Python
imports.upload_state()
CLI
openemail imports upload-state

imports.upload_chunk

Upload one part of an import file

الصلاحياتthreads:write
التوقيع
upload_chunk(id, file, chunk, data, api_key: nil) -> Hash

Stores one part of file file: the bytes from chunk * chunkBytes up to the next part. Every part is exactly chunkBytes long except the last, and a part of the wrong length is 400 bad_chunk. Sending a part again replaces it, so a failed part can simply be retried.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

fileIntegerمطلوب

The file index, in the order given to create.

chunkIntegerمطلوب

The part index, from 0.

dataString, IO or Pathnameمطلوب

The part as a binary String, or an IO or a Pathname whose whole content is the part. It is sent as it is, so slice the part out of the file first.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash echoing file, chunk and the bytes stored.

مثال

size = File.size("takeout-001.zip")item = client.imports.create(addressId: "addr_2b7e", files: [{name: "takeout-001.zip", bytes: size}])part = File.binread("takeout-001.zip", item[:chunkBytes], 0) client.imports.upload_chunk(item[:id], 0, 0, part)

ملاحظات

  • Retried automatically on network failure and on 408, 429 and 5xx responses, since a repeated part replaces itself.

متاح أيضًا في

API
PUT /imports/{id}/files/{file}/chunks/{chunk}
TypeScript
imports.uploadChunk()
Python
imports.upload_chunk()
CLI
openemail imports upload-chunk

imports.start

Queue an import once its files are uploaded

الصلاحياتthreads:write
التوقيع
start(id, api_key: nil) -> Hash

Checks that every part of every file has arrived, recognises each file's format and queues the import. A file still missing parts is 412 missing_chunks, and a file that is not an archive or a mailbox is 400 unsupported_file. Calling it on an import that has already left uploading returns it unchanged.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

The import Hash, shaped like the one get returns, with status set to queued.

مثال

queued = client.imports.start("imp_3f9c2a7b1e4d8f60a5c7b92d") puts queued[:status]

ملاحظات

  • Retried automatically on network failure and on 408, 429 and 5xx responses, since calling it again returns the import unchanged.

متاح أيضًا في

API
POST /imports/{id}/start
TypeScript
imports.start()
Python
imports.start()
CLI
openemail imports start

imports.cancel

Cancel a mailbox import

الصلاحياتthreads:write
التوقيع
cancel(id, api_key: nil) -> Hash

Stops an import at its next checkpoint. Mail already imported stays in the mailbox. A finished import is 409 not_cancellable.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

The import Hash, shaped like the one get returns, with status set to cancelled.

مثال

client.imports.cancel("imp_3f9c2a7b1e4d8f60a5c7b92d")

متاح أيضًا في

API
POST /imports/{id}/cancel
TypeScript
imports.cancel()
Python
imports.cancel()
CLI
openemail imports cancel

imports.list_failures

List what an import could not bring across

الصلاحياتthreads:read
التوقيع
list_failures(id, after: nil, limit: nil, api_key: nil) -> Hash

Each message or archive entry that did not come across, with the reason: too-large (over 50 MB), unparseable, no-date, storage-error, unreadable-entry, encrypted-entry or archive-limit. Page with after:, passing the nextCursor of the previous page.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

afterInteger

The nextCursor of the previous page.

limitInteger

At most 100, the default.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash, not an OpenEmail::Page, with data, an Array of Hashes with id, seq, reason, subject, sender, messageId, source, bytes, detail and createdAt, and nextCursor, an Integer or nil on the last page.

مثال

failures = client.imports.list_failures("imp_3f9c2a7b1e4d8f60a5c7b92d") failures[:data].each { |failure| puts "#{failure[:reason]} #{failure[:subject]}" }

متاح أيضًا في

API
GET /imports/{id}/failures
TypeScript
imports.listFailures()
Python
imports.list_failures()
CLI
openemail imports list-failures

imports.delete_upload

Delete the files uploaded for an import

الصلاحياتthreads:write
التوقيع
delete_upload(id, api_key: nil) -> Hash

Removes the uploaded archive. Mail already imported stays in the mailbox. An import still uploading is cancelled at the same time, and one that is queued or running is 409 still_running.

المعلمات

idStringمطلوب

Import id, imp_ followed by 24 hex characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

The import Hash, shaped like the one get returns, with uploadDeleted set to true.

مثال

client.imports.delete_upload("imp_3f9c2a7b1e4d8f60a5c7b92d")

متاح أيضًا في

API
DELETE /imports/{id}/upload
TypeScript
imports.deleteUpload()
Python
imports.delete_upload()
CLI
openemail imports delete-upload

imports.import_files

Create, upload and start an import in one call

الصلاحياتthreads:write
التوقيع
import_files(input = nil, api_key: nil, **fields, &block) -> Hash

Creates the import, uploads every file part by part and starts it, reporting progress to a block or through onProgress. Pass each file's data as a binary String, an IO or a Pathname; parts are sliced from it, so a Pathname or an open File is never read into memory at once.

It returns once the import is queued. Poll get to follow it.

المعلمات

addressIdStringمطلوب

The address the mail belongs to.

filesArray<Hash>مطلوب

Each file as a Hash with name and data, where data is a binary String, an IO or a Pathname.

optionsHash

keepInbox, includeSpam and includeTrash, as for create.

onProgressProc

Anything that responds to call, called after each part with the bytes uploaded and the total. A block given to the call does the same job and is used instead when both are given.

api_keyString

Overrides the client API key for this call only.

يُرجع

The import Hash, shaped like the one get returns, with status set to queued.

مثال

files = [{name: "takeout-001.zip", data: Pathname("takeout-001.zip")}] item = client.imports.import_files(addressId: "addr_2b7e", files:) do |done, total|  puts "#{(done * 100.0 / total).round}%"end puts item[:id], item[:status]

ملاحظات

  • If a part fails after its retries, the import is left in uploading; upload_state then tells you which parts to send before calling start.

متاح أيضًا في

API
POST /imports
TypeScript
imports.importFiles()
Python
imports.import_files()
CLI
openemail imports import-files