Prompt
Prompt
typescriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "task_dryrun",6},7async () => {8// Perform a dry-run and show the output to the operator with a display.9const dryRun = await airplane.execute("my_task_slug", {10dry_run: true,11});12await airplane.display.json(dryRun.output);1314// Ask the operator if we should continue.15const { ok } = await airplane.prompt(16{ ok: "boolean" },17{18description: `Review the dry-run output above. If it looks correct, select OK to apply the changes.`,19},20);21if (!ok) {22await airplane.display.text("Exiting due to bad dryrun");23return;24}2526// If confirmed, we can re-run:27const run = await airplane.execute("my_task_slug", {28dry_run: false,29});3031return run.output;32},33);
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
Reviewers that are allowed to approve the prompt. If no reviewers are provided, anyone that can see the active run is allowed to approved.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
Promise of a mapping from parameter slugs to the values returned in the prompt response.
pythonCopied1import airplane234@airplane.task()5def task_dryrun():6# Perform a dry-run and show the output to the operator with a display.7dry_run = airplane.execute(8"my_task_slug",9{10"dry_run": True,11},12)13airplane.display.json(dry_run.output)14# Ask the operator if we should continue.15airplane.prompt(16description=(17"Review the dry-run output above. If it looks correct, "18"click OK to apply the changes."19),20reviewers=airplane.PromptReviewers(21groups=["eng-managers"],22# Also accepts a list of users:23users=["jill@company.com", "jack@company.com"],24),25)26# If confirmed, we can re-run:27run = airplane.execute(28"my_task_slug",29{30"dry_run": False,31},32)
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
Reviewers that are allowed to approve the prompt. If no reviewers are provided, anyone that can see the active run is allowed to approved.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
If true, the prompt will be created in the background and a Prompt
object will be returned. To wait for the prompt to be submitted, call prompt.wait()
.
Mapping of parameter slugs to the values submitted in the prompt.
If the prompt cannot be created properly.
If the request times out.
If a network error occurs.
Background prompt
typescriptCopied1// Create a prompt in the background2const myPrompt = await airplane.prompt.background({ deploy_succeeded: "boolean" });34// Wait for the prompt to be submitted5const { deploy_succeeded } = await myPrompt.wait();67// Get the prompt submitter8const { name, email } = await myPrompt.submitter();
Defines the parameter form as a mapping of slug to parameter. The values will be returned as an object that maps the parameter slug to the corresponding value. To learn more about parameters, see the Parameter documentation.
Reviewers that are allowed to approve the prompt. If no reviewers are provided, anyone that can see the active run is allowed to approved.
Text of the confirmation button on the prompt dialog.
Text of the cancellation button on the prompt dialog.
Prompt description to display. Supports markdown.
Promise of Prompt
object. See below for details on the methods exposed by the latter.
Returns a Promise<PromptOutputParams>
containing a mapping of each parameter slug to the submitted value.
Returns a Promise<{name: string, email: string, userID: string}>
containing details on the user who submitted the prompt.
pythonCopied1# Create a prompt in the background2my_prompt = airplane.prompt({"deploy_succeeded": bool}, background=True)34# Wait for the prompt to be submitted5values = my_prompt.wait()67# Get the prompt submitter8submitter = my_prompt.submitter()
airplane.prompt
(documented
above) with background=True
. The latter will return a Prompt
object.Returns a Dict[str, Any]
containing a mapping of each parameter slug to the submitted value.
Returns a User
object containing id
, email
, and name
fields for the user who submitted the prompt.