Set port mappings
curl --request PUT \
--url https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports \
--header 'Content-Type: application/json' \
--data '
{
"ports": [
{
"vm_port": 32768,
"protocol": "tcp"
}
]
}
'import requests
url = "https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports"
payload = { "ports": [
{
"vm_port": 32768,
"protocol": "tcp"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ports: [{vm_port: 32768, protocol: 'tcp'}]})
};
fetch('https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports', 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://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'ports' => [
[
'vm_port' => 32768,
'protocol' => 'tcp'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports"
payload := strings.NewReader("{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
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.put("https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports")
.header("Content-Type", "application/json")
.body("{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "<string>",
"host_port": 123,
"vm_port": 123,
"protocol": "<string>",
"host_address": "<string>"
}
]{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}CVMs
Set port mappings
Bulk-replace all port mappings for this CVM. Writes to DB and applies to VMM.
PUT
/
api
/
v1
/
cvms
/
{cvm_id}
/
ports
Set port mappings
curl --request PUT \
--url https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports \
--header 'Content-Type: application/json' \
--data '
{
"ports": [
{
"vm_port": 32768,
"protocol": "tcp"
}
]
}
'import requests
url = "https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports"
payload = { "ports": [
{
"vm_port": 32768,
"protocol": "tcp"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ports: [{vm_port: 32768, protocol: 'tcp'}]})
};
fetch('https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports', 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://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'ports' => [
[
'vm_port' => 32768,
'protocol' => 'tcp'
]
]
]),
CURLOPT_HTTPHEADER => [
"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://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports"
payload := strings.NewReader("{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
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.put("https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports")
.header("Content-Type", "application/json")
.body("{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/ports")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"ports\": [\n {\n \"vm_port\": 32768,\n \"protocol\": \"tcp\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "<string>",
"host_port": 123,
"vm_port": 123,
"protocol": "<string>",
"host_address": "<string>"
}
]{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Path Parameters
Body
application/json
Bulk-replace all port mappings for a CVM.
Show child attributes
Show child attributes
Was this page helpful?
⌘I

