Start a disk upload
curl --request POST \
--url https://api.ornn.com/v1/orchestrator/disks/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"display_name": "Training disk"
}
'import requests
url = "https://api.ornn.com/v1/orchestrator/disks/uploads"
payload = { "display_name": "Training disk" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({display_name: 'Training disk'})
};
fetch('https://api.ornn.com/v1/orchestrator/disks/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ornn.com/v1/orchestrator/disks/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Training disk'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ornn.com/v1/orchestrator/disks/uploads"
payload := strings.NewReader("{\n \"display_name\": \"Training disk\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ornn.com/v1/orchestrator/disks/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Training disk\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ornn.com/v1/orchestrator/disks/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Training disk\"\n}"
response = http.request(request)
puts response.read_body{
"id": "44444444-4444-4444-8444-444444444444",
"upload_mode": "signed_put",
"upload_url": "https://uploads.example.com/disk.qcow2?signature=example",
"upload_method": "PUT",
"upload_headers": {
"Content-Type": "application/x-qemu-disk"
},
"expires_in_seconds": 3600
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}Start a disk upload
Returns a transfer target for a qcow2 disk of up to 64 GiB. Send display_name for a new upload
and save the returned disk ID. Send that ID as disk_id to resume or replace an upload. Disks
built from base images can’t be replaced this way.
For signed_put, send raw bytes to upload_url using the returned method and headers. Keep
your Ornn key out of that request. For local_proxy, use the authenticated disk-bytes endpoint.
Complete the upload after the transfer. Use a read-write key from an approved organization.
POST
/
v1
/
orchestrator
/
disks
/
uploads
Start a disk upload
curl --request POST \
--url https://api.ornn.com/v1/orchestrator/disks/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"display_name": "Training disk"
}
'import requests
url = "https://api.ornn.com/v1/orchestrator/disks/uploads"
payload = { "display_name": "Training disk" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({display_name: 'Training disk'})
};
fetch('https://api.ornn.com/v1/orchestrator/disks/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ornn.com/v1/orchestrator/disks/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'display_name' => 'Training disk'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ornn.com/v1/orchestrator/disks/uploads"
payload := strings.NewReader("{\n \"display_name\": \"Training disk\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ornn.com/v1/orchestrator/disks/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"display_name\": \"Training disk\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ornn.com/v1/orchestrator/disks/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"display_name\": \"Training disk\"\n}"
response = http.request(request)
puts response.read_body{
"id": "44444444-4444-4444-8444-444444444444",
"upload_mode": "signed_put",
"upload_url": "https://uploads.example.com/disk.qcow2?signature=example",
"upload_method": "PUT",
"upload_headers": {
"Content-Type": "application/x-qemu-disk"
},
"expires_in_seconds": 3600
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"detail": "<string>"
}Upload a qcow2 file, then complete it before selecting its disk ID for a VM.
The file must include the dependencies described in the VM disk guide.
For a
import os
from pathlib import Path
import requests
api = "https://api.ornn.com"
client = requests.Session()
client.headers["Authorization"] = f"Bearer {os.environ['ORNN_API_KEY']}"
started = client.post(
f"{api}/v1/orchestrator/disks/uploads",
json={"display_name": "Training disk"},
timeout=30,
)
started.raise_for_status()
target = started.json()
disk_id = target["id"]
print(f"Disk ID for retries or deletion: {disk_id}", flush=True)
if target["upload_mode"] != "signed_put":
raise RuntimeError(f"Use the Upload disk bytes endpoint for disk {disk_id}")
with Path("training.qcow2").open("rb") as disk_file:
# Use a separate request: never send the Ornn API key to the signed URL.
transfer = requests.request(
target["upload_method"],
target["upload_url"],
headers=target["upload_headers"],
data=disk_file,
timeout=900,
)
transfer.raise_for_status()
completed = client.post(
f"{api}/v1/orchestrator/disks/uploads/{disk_id}/complete",
json={},
timeout=900,
)
completed.raise_for_status()
disk = completed.json()
if not disk["sha256"]:
raise RuntimeError("The uploaded disk is not ready")
print(disk["id"], disk["sha256"])
local_proxy target, use Upload disk bytes
with the returned disk ID, then complete the upload.
If a transfer expires or fails, request a new target with {"disk_id": "<saved-disk-id>"}.
Use Delete a disk to discard an unfinished upload.Authorizations
Send an organization API key as a bearer token.
Body
application/json
Response
Start a disk upload.
Was this page helpful?