postProjectsBySlugDeployments method
- String slug,
- ProjectsDeployStart projectsDeployStart
Opens a deployment and hands back a short-lived, prefix-scoped grant to write its bytes straight to object storage.
Opens a deployment and hands back a short-lived, prefix-scoped grant to write its bytes straight to object storage. Answers 202. This is the path for a site too large to send as one archive: a real export is hundreds of megabytes against a 16 MiB body limit, so the bytes deliberately do NOT pass through the API. The answer carries bucket, prefix and upload — a presigned POST policy that S3 itself confines to this site's prefix (starts-with <org>/<slug>/), expires in 30 minutes and bounds each object. So a build writes its own files and holds no standing bucket credential; there is nothing to rotate and nothing that leaks between tenants. Never guess the prefix — it is server-derived, and a guessed one lands where nothing is served. The deployment is queued until POST .../deployments/{id}/complete flips it live (or error). That completion is also where DELETION happens: the grant authorizes writes only, so a build cannot remove a file, and cloud reconciles the prefix against the keys manifest the completion carries. A build that dies before completing leaves the deployment queued rather than a half-live site. The grant is on the 202 and NOWHERE else — it is never stored and never replayed on a later read, so it cannot outlive the build it was minted for. A deployment whose grant could not be minted is still created and still completable; it simply carries no upload, and a caller with no other way to write should treat that as the failure it is. Billing: the hosting gate runs BEFORE anything is created (402 unfunded, 503 commerce unreachable), and the debit lands on the completion that goes live — never on a queued or failed build. Scope: a validated principal is required (403 without one) and the site is resolved within that principal's org, so another tenant's slug is a 404.
Parameters:
-
String slug (required): Slug is the site to deploy, from the path.
-
ProjectsDeployStart projectsDeployStart (required):
Implementation
Future<ProjectsDeployment?> postProjectsBySlugDeployments(String slug, ProjectsDeployStart projectsDeployStart,) async {
final response = await postProjectsBySlugDeploymentsWithHttpInfo(slug, projectsDeployStart,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ProjectsDeployment',) as ProjectsDeployment;
}
return null;
}