curl --request POST \
--url https://api.example.com/api/v1/allocations/{id}/swap/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"outbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": false
}
'import requests
url = "https://api.example.com/api/v1/allocations/{id}/swap/"
payload = {
"outbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": False
}
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({
outbound_device_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
inbound_device_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
dry_run: false
})
};
fetch('https://api.example.com/api/v1/allocations/{id}/swap/', 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.example.com/api/v1/allocations/{id}/swap/",
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([
'outbound_device_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'inbound_device_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'dry_run' => false
]),
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.example.com/api/v1/allocations/{id}/swap/"
payload := strings.NewReader("{\n \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\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.example.com/api/v1/allocations/{id}/swap/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/allocations/{id}/swap/")
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 \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\n}"
response = http.request(request)
puts response.read_body{
"allocation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": true,
"outbound_device": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"inbound_device": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}Swap a device in an allocation
Atomically replace one device in this allocation with another, for a physical node swap. An allocation must always name the devices currently contracted to the tenant, so when a tray leaves the customer’s rack and a spare takes its slot the membership has to follow. Both writes commit in one transaction, so a concurrent read sees the outbound device or the inbound one, never both and never neither. Unlike assign/unassign there is no partial success: an inbound device that is unknown, outside the allocation’s site, inventory-only, already a member, or held by an overlapping allocation fails the whole call. Dry runs validate the swap without changing memberships.
curl --request POST \
--url https://api.example.com/api/v1/allocations/{id}/swap/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"outbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": false
}
'import requests
url = "https://api.example.com/api/v1/allocations/{id}/swap/"
payload = {
"outbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"inbound_device_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": False
}
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({
outbound_device_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
inbound_device_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
dry_run: false
})
};
fetch('https://api.example.com/api/v1/allocations/{id}/swap/', 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.example.com/api/v1/allocations/{id}/swap/",
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([
'outbound_device_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'inbound_device_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'dry_run' => false
]),
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.example.com/api/v1/allocations/{id}/swap/"
payload := strings.NewReader("{\n \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\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.example.com/api/v1/allocations/{id}/swap/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/allocations/{id}/swap/")
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 \"outbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"inbound_device_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"dry_run\": false\n}"
response = http.request(request)
puts response.read_body{
"allocation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dry_run": true,
"outbound_device": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
},
"inbound_device": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}{
"detail": "<string>",
"code": "error",
"field_errors": [
{
"field": "<string>",
"messages": [
"<string>"
]
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Path Parameters
A UUID string identifying this allocation.
Body
Inbound and outbound device for an atomic allocation membership swap.
Device UUID to remove. Must currently be a member of this allocation.
Device UUID to add. Must be in the allocation's site, allocatable, and free of allocations overlapping this one.
Validate the swap and return the planned outcome without changing memberships.
Response
Typed result for a live allocation device swap or dry run.