Provisionally create a new machine version migration.
This operation returns a code upload URL and fields that can be used to upload the code for the machine version migration.
Once the code is uploaded, call PUT /machines/:machineSlug/migrations/:machineVersionMigrationId
with the machineVersionMigrationId
returned from this operation to
finalize the creation of the machine version migration.
Path parameters
-
The slug/name for the machine definition this version is related to.
Minimum length is
1
. Format should match the following pattern:^[a-zA-Z0-9_-]{1,128}$
.
Query parameters
-
gzip boolean
Will the code be uploaded gzipped?
Body
Request to provisionally create a machine version migration.
-
The ID of a machine definition version.
-
The ID of a machine definition version.
Responses
-
The machine version migration was provisionally created successfully.
Now, post the code for the machine version migration as follows:
const { codeUploadFields, codeUploadUrl } = await provisionalVersionMigrationCreationResponse.json(); const uploadForm = new FormData(); for (const [key, value] of Object.entries(codeUploadFields)) { uploadForm.append(key, value as string); } uploadForm.set("content-type", "application/javascript"); uploadForm.append( "file", new Blob(["javascript-code-here"], { type: "application/javascript", }), "your-file-name.js", ); const uploadRes = await fetch( codeUploadUrl, { method: "POST", body: uploadForm, }, );
And then finalize the creation of the machine version migration by calling
PUT /machines/:machineSlug/migrations/:machineVersionMigrationId
with themachineVersionMigrationId
returned from this operation. -
The request was unauthorized.
-
The request was malformed.
curl \
-X POST https://api.statebacked.dev/machines/my-machine/migrations \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fromMachineVersionId":"string","toMachineVersionId":"string"}'
{
"fromMachineVersionId": "string",
"toMachineVersionId": "string"
}
{
"fromMachineVersionId": "string",
"toMachineVersionId": "string"
}
{
"machineVersionMigrationId": "string",
"codeUploadUrl": "string",
"codeUploadFields": {}
}
{
"machineVersionMigrationId": "string",
"codeUploadUrl": "string",
"codeUploadFields": {
"Additional properties:": "string"
}
}
{
"error": "string",
"code": "missing-scope"
}
{
"error": "string",
"code": "missing-scope"
}
{
"error": "string",
"code": "specify-org",
"parameter": "string"
}
{
"error": "string",
"code": "specify-org",
"parameter": "string"
}