Skip to main content

Save an export as a preset

An export is a choice of targets, each target's options and, often, where the result is delivered (for every way to export several things at once, see Export several at once). When you run the same combination again — a nightly sync, a release export — save it as a preset and apply it by name instead of choosing everything again. A preset belongs to the workspace and works in Export studio, the CLI and the API.

A preset holds:

  • Targets: one target, or up to 16 for an export with one folder per target.
  • Options: each target's options. They are checked against that target's options when the preset is saved, and again every time it is applied, so a preset an emitter has since outgrown is refused rather than guessed at.
  • Delivery: optionally, up to five delivery profiles, in order, that the export is delivered with as soon as it finishes.

The source — which item, which version — is never part of a preset. You choose it each time, or let every publish of a project run the preset: see Export automatically on every publish.

Before you start​

  • The projects:edit permission to save, change or delete a preset. Reading presets needs projects:view.
  • Applying a preset needs whatever the export needs. A preset with a delivery profile also needs versions:publish, as any delivery does.

Save a preset in Export studio​

  1. Open an export in Export studio and choose its target and options (or tick Several targets).
  2. On Review, optionally tick a profile under Deliver when it completes.
  3. Click Save as preset, enter a Preset name and a Description, and click Save preset.

The preset keeps the targets, the options you changed and every ticked delivery profile, in order. Apply it again and you get exactly the same export.

Run it on every publish from Review​

Under Save as preset on Review, Auto-export on publish runs the preset in play on every publish of this project. The preset in play is the one you just saved, or the one you applied and haven't changed since.

  1. Save the export as a preset, or apply one and leave its targets, options and delivery as they are.
  2. Tick Run preset on every publish of this project. Delivery halts at critical loss.
  3. To stop, clear the tick.
Review in Export studio: Save as preset with nightly-sync named and its two ticked delivery profiles, and Auto-export on publish with Run nightly-sync on every publish of this project ticked, halting at critical lossReview in Export studio: Save as preset with nightly-sync named and its two ticked delivery profiles, and Auto-export on publish with Run nightly-sync on every publish of this project ticked, halting at critical loss
Route/ade/dashboard/export/studio

Change something after applying a preset, and the box asks you to save it as a preset first. To halt at any loss, pre-approve loss or see the runs, click Manage on Presets (see Export automatically on every publish). A catalog item has no publishes, so the box isn't shown there.

Apply a preset in Export studio​

On the Target step, choose a preset under Apply a preset and click Apply:

  • A one-target preset selects that target with its options.
  • A multi-target preset ticks its targets under Several targets, each with its options.
  • Its delivery profiles are ticked, in order, under Deliver when it completes on Review.

A target this source can't export to is named under the picker and left out. Continue to Verify and Generate as usual; you can still change anything before you generate.

Open a preset in Studio​

On the Presets tab, Open in Studio starts a new export with the preset. Choose the source, and the studio applies the preset on Target.

The quick Export dialog on a version or catalog item has the same Apply a preset picker and Save as preset button on its Target step (see The Export dialog).

Manage presets​

The Presets tab of Export studio lists the workspace's presets, each with its targets, its delivery profiles and the CLI command that runs it.

The Presets tab of Export studio: nightly-sync with two targets, OpenAPI with its version option and Protocol Buffers, delivered with lake and release-bucket, and release-graphql with one target and no delivery; each has Open in Studio, Auto-export, Edit and DeleteThe Presets tab of Export studio: nightly-sync with two targets, OpenAPI with its version option and Protocol Buffers, delivered with lake and release-bucket, and release-graphql with one target and no delivery; each has Open in Studio, Auto-export, Edit and Delete
Route/ade/dashboard/export/studio?tab=presets
  • Edit changes the Name, the Description, the Targets — each a format and its Options (JSON), added with Add target — and the Delivery profiles. Tick up to five; they deliver in the order you tick them (#1, #2…), and none ticked means export only. Click Save changes; every problem is listed at once.
  • Delete asks you to confirm with Delete name. Exports already started with the preset are not affected.
Editing nightly-sync: its name and description, two targets with their JSON options, Add target, and the delivery profiles lake (#1) and release-bucket (#2) ticked, contracts-repo notEditing nightly-sync: its name and description, two targets with their JSON options, Add target, and the delivery profiles lake (#1) and release-bucket (#2) ticked, contracts-repo not
Route/ade/dashboard/export/studio?tab=presets

Members without projects:edit see the presets read-only.

Use presets from the CLI​

# Save a preset: targets in order, TARGET:KEY=VALUE options (values parsed as JSON), a delivery profile
apiome export presets create nightly-sync \
--target openapi --option 'openapi:openapi_version="3.0"' \
--target protobuf --deliver data-lake --description "Every night, for the data lake"

# Run it on an item (or --items for several)
apiome export --preset nightly-sync orders --version 1.4.0 --out ./orders-export

A one-target preset writes its file like apiome export <format>; a multi-target preset or --items writes an archive with a folder per target and prints each outcome. --deliver PROFILE adds a delivery after the preset's own, and every delivery's outcome prints after the download.

apiome export presets also has list, show, update (--target replaces the targets; --no-deliver removes delivery) and delete. Every option is in the CLI reference.

Use presets from the API​

Save a preset with its targets and options:

curl -X POST "$APIOME/v1/export/acme/presets" \
-H "Authorization: Bearer $APIOME_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "nightly-sync",
"targets": [{"target": "openapi", "options": {"openapi_version": "3.0"}}, {"target": "protobuf"}],
"deliveryProfileIds": ["<profile id>", "<another profile id>"]}'
AnswerWhy
400A target is unknown, an option isn't valid for its target, two targets are the same format, or a delivery profile doesn't exist (deliveryProfileIds[1]: …). Every problem is listed in errors.
409Another preset in the workspace already has that name.

Apply it by naming it, by name or id, when you start a job — instead of target, targets and options:

curl -X POST "$APIOME/v1/export/acme/jobs" \
-H "Authorization: Bearer $APIOME_API_KEY" -H "Content-Type: application/json" \
-d '{"artifact": "<artifact id>", "version": "1.4.0", "preset": "nightly-sync"}'

The preset's targets and options stand in for the job's, and its delivery profiles go first, in order, among delivery_profiles (at most five in all). Everything else — the source, version, items, overlays, confirm, dry_run — is the request's own; a dry run isn't delivered. An unknown preset, or one whose options no longer validate, is refused with 400.

GET /v1/export/acme/presets lists presets, GET …/presets/{preset} reads one by id or name, PATCH …/presets/{id} changes one (targets and deliveryProfileIds are replaced whole; "deliveryProfileIds": [] removes delivery) and DELETE …/presets/{id} removes one. Saving, changing and deleting are recorded in the audit log as export.preset.created, .updated and .deleted. Every field is in the export presets reference.