client.Exports
Jede Methode in diesem Namespace: ihre Signatur, ihre Parameter, was sie zurückgibt und ein Beispiel.
Methoden
A zip of the whole workspace, as the Export page makes it: see what it would hold, start one, follow it while it is made and download it once it is ready.
Exports.Preview
See what an export would hold
Preview(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Returns whether the workspace can be exported by the caller now, when the next export can start, the export still being made, if there is one, and how much an export would hold: conversations, attachments and their size, contacts, audiences, calendar events, templates, rules, labels, notes and addresses. When allowed is false, reason says why and counts is null.
Only the workspace owner, or a member whose role holds every permission, can export the workspace: an API key, or an access token connected with every address. A key or token limited to particular addresses or domains is 422 capability_unsupported, and an account the workspace cannot export for is 403 export_not_permitted.
Parameter
openemail.WithAPIKeystringOverrides the client's API key for this call only.
Rückgabe
An openemail.Object with allowed, reason, nextAvailableAt, activeExportId and counts.
Beispiel
preview, err := client.Exports.Preview(ctx)if err != nil { return err} fmt.Println(preview.Bool("allowed"), preview.String("nextAvailableAt"))Hinweise
reasonisnot-permitted,mailbox-loginortwo-factor-required.
Auch verfügbar über
Exports.List
List the exports
List(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Returns every export of the workspace, newest first, a page at a time, with its status, its progress through the conversations and, once it is ready, its size, file name and when it is deleted.
Only the workspace owner, or a member whose role holds every permission, can export the workspace: an API key, or an access token connected with every address. A key or token limited to particular addresses or domains is 422 capability_unsupported, and an account the workspace cannot export for is 403 export_not_permitted.
Parameter
openemail.WithLimitintExports per page, from 1 to 100. The server defaults to 25.
openemail.WithOffsetintHow many exports to skip.
openemail.WithAPIKeystringOverrides the client's API key for this call only.
Rückgabe
An openemail.Object with data, total and hasMore.
Beispiel
export, err := client.Exports.List(ctx)if err != nil { return err} fmt.Println(export.String("object"))Hinweise
A workspace can be exported once a day, and each export is kept for a year, so the list stays short.
Auch verfügbar über
- API
GET /exports- TypeScript
exports.list()- Python
exports.list()- Ruby
exports.list- PHP
exports->list- Java
exports().list- C#
Exports.ListAsync- CLI
openemail exports list
Exports.Get
Retrieve an export
Get(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)Returns one export: its status, phase and progress while it is made, and once it is ready its size, file name and when it is deleted.
Only the workspace owner, or a member whose role holds every permission, can export the workspace: an API key, or an access token connected with every address. A key or token limited to particular addresses or domains is 422 capability_unsupported, and an account the workspace cannot export for is 403 export_not_permitted.
Parameter
idstringErforderlichThe export id from
StartorList.openemail.WithAPIKeystringOverrides the client's API key for this call only.
Rückgabe
An openemail.Object.
Beispiel
item, err := client.Exports.Get(ctx, "exp_8c1e4a7f2b9d3e6a0c5f1b28")if err != nil { return err} fmt.Println(item.String("status"), item.Int("threadsDone"), item.Int("threadsTotal"))Hinweise
An unknown id is a 404.
Auch verfügbar über
- API
GET /exports/{id}- TypeScript
exports.get()- Python
exports.get()- Ruby
exports.get- PHP
exports->get- Java
exports().get- C#
Exports.GetAsync- CLI
openemail exports get
Exports.Start
Start an export
Start(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Starts making a zip of the whole workspace, as Export now on the Export page does, and returns with the export, queued. It is made in the background: poll Get until status is ready, then Download it. One export runs at a time, and a workspace can be exported once a day.
Only the workspace owner, or a member whose role holds every permission, can export the workspace: an API key, or an access token connected with every address. A key or token limited to particular addresses or domains is 422 capability_unsupported, and an account the workspace cannot export for is 403 export_not_permitted.
Parameter
openemail.WithAPIKeystringOverrides the client's API key for this call only.
Rückgabe
An openemail.Object for the new export.
Beispiel
started, err := client.Exports.Start(ctx)if err != nil { return err} fmt.Println(started.String("id"), started.String("status"))Hinweise
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.An export already being made is 409
already_running, and a workspace exported in the last day is 429export_limit_reached.The SDK does not retry it.
Auch verfügbar über
- API
POST /exports- TypeScript
exports.start()- Python
exports.start()- Ruby
exports.start- PHP
exports->start- Java
exports().start- C#
Exports.StartAsync- CLI
openemail exports start
Exports.Download
Download an export
Download(ctx context.Context, id string, opts ...openemail.RequestOption) ([]byte, error)Returns the zip of a ready export, the same file the Download action on the Export page saves.
Only the workspace owner, or a member whose role holds every permission, can export the workspace: an API key, or an access token connected with every address. A key or token limited to particular addresses or domains is 422 capability_unsupported, and an account the workspace cannot export for is 403 export_not_permitted.
Parameter
idstringErforderlichThe export id from
StartorList.openemail.WithAPIKeystringOverrides the client's API key for this call only.
Rückgabe
A []byte holding the zip.
Beispiel
data, err := client.Exports.Download(ctx, "exp_8c1e4a7f2b9d3e6a0c5f1b28")if err != nil { return err} fmt.Println(len(data), "bytes")Hinweise
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.Before the export is
readythe call is 409export_not_ready, and an export older than a year is 409expired.The whole zip is held in memory, and a large workspace makes a large zip.