Skip to content
← Public packages

@cameronpak/box

Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.

src/get-deletion-operation.ts

20 lines · 791 B · TypeScript
import { assertOperationId, boxRequest, failure, type Result } from './client.ts'
import type { DeletionOperation } from './types.ts'

export type GetDeletionOperationInput = { operationId: string }

export type GetDeletionOperationOutput = { operation: DeletionOperation }

/**
 * Poll an accepted Box or snapshot deletion operation until status is completed.
 * Statuses are pending, processing, blocked, and completed.
 */
export default async function getDeletionOperation(
	input: GetDeletionOperationInput,
): Promise<Result<GetDeletionOperationOutput>> {
	const invalid = assertOperationId(input?.operationId)
	if (invalid) return failure<GetDeletionOperationOutput>(invalid)
	return boxRequest<GetDeletionOperationOutput>({
		path: '/deletion-operations/' + input.operationId,
	})
}