Python (SDK)
import latitudesh_python_sdk
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.servers.update(server_id="sv_yQrJdNAGO30gv", data={
"id": "sv_yQrJdNAGO30gv",
"type": latitudesh_python_sdk.UpdateServerServersType.SERVERS,
"attributes": {
"project": "proj_yQrJdNMGO30gv",
},
})
# Handle response
print(res)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.Servers.Update(ctx, "sv_yQrJdNAGO30gv", operations.UpdateServerServersRequestBody{
Data: &operations.UpdateServerServersData{
ID: latitudeshgosdk.Pointer("sv_yQrJdNAGO30gv"),
Type: operations.UpdateServerServersTypeServers.ToPointer(),
Attributes: &operations.UpdateServerServersAttributes{
Project: latitudeshgosdk.Pointer("proj_yQrJdNMGO30gv"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Server != nil {
// handle response
}
}import { Latitudesh } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.servers.update({
serverId: "sv_yQrJdNAGO30gv",
requestBody: {
data: {
id: "sv_yQrJdNAGO30gv",
type: "servers",
attributes: {
project: "proj_yQrJdNMGO30gv",
},
},
},
});
console.log(result);
}
run();curl --request PATCH \
--url https://api.latitude.sh/servers/{server_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"id": "sv_yQrJdNAGO30gv",
"type": "servers",
"attributes": {
"project": "proj_yQrJdNMGO30gv"
}
}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
id: 'sv_yQrJdNAGO30gv',
type: 'servers',
attributes: {project: 'proj_yQrJdNMGO30gv'}
}
})
};
fetch('https://api.latitude.sh/servers/{server_id}', 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.latitude.sh/servers/{server_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'id' => 'sv_yQrJdNAGO30gv',
'type' => 'servers',
'attributes' => [
'project' => 'proj_yQrJdNMGO30gv'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.latitude.sh/servers/{server_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"id\": \"sv_yQrJdNAGO30gv\",\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_yQrJdNMGO30gv\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/servers/{server_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"id\": \"sv_yQrJdNAGO30gv\",\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_yQrJdNMGO30gv\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "sv_yQrJdNAGO30gv",
"type": "servers",
"attributes": {
"tags": [],
"hostname": "Lightweight Wooden Knife",
"label": "136877NODEKM",
"price": 599,
"role": "Bare Metal",
"primary_ipv4": "214.249.69.62",
"primary_ipv6": "b0c8:139:6f83:7f0c:6e2:33a3:78e4:e03f",
"status": "unknown",
"ipmi_status": "Normal",
"created_at": null,
"scheduled_deletion_at": null,
"locked": false,
"rescue_allowed": false,
"region": {
"city": "Frankfurt 115",
"country": "Germany 107",
"site": {
"id": "loc_aNmodjGyqbE8W",
"name": "Frankfurt 115",
"slug": "FRA96",
"facility": "Frankfurt 115",
"rack_id": "rack_byQrJdNJd30gv"
}
},
"team": {
"id": "team_YQZmYB34Nxso86ZgyKj2UEPEnyA",
"name": "348 Team",
"slug": "348-team",
"description": "348 Team",
"address": "51588 Goodwin Mission, Port Oswaldo, KS 14871-0638",
"currency": {
"id": "cur_GnzRD5xAqM5yw",
"code": "agd",
"name": "daznioxpdspfbdbvvikg",
"currency_id": null
},
"status": "verified",
"feature_flags": [],
"limits": {
"bare_metal": 5,
"bare_metal_gpu": 1,
"virtual_machine": 5,
"virtual_machine_gpu": 3,
"elastic_ip": 5,
"virtual_network": 5,
"database": null,
"filesystem": null,
"block_storage": null
}
},
"project": {
"id": "proj_yQrJdNMGO30gv",
"name": "Awesome Wool Computer",
"slug": "awesome-wool-computer",
"description": "Practical Rubber Shirt",
"provisioning_type": "on_demand",
"billing_type": "Normal",
"billing_method": "Normal",
"bandwidth_alert": false,
"environment": null,
"billing": {},
"stats": {
"databases": 0,
"ip_addresses": 0,
"prefixes": 0,
"servers": 1,
"storages": 0,
"virtual_machines": 0,
"vlans": 0
}
},
"plan": {
"id": "plan_3YjJOLLyOvZ87",
"name": "c2.large.arm",
"slug": "c2-large-arm",
"billing": "hourly"
},
"interfaces": [],
"operating_system": {},
"specs": {
"cpu": "",
"disk": "",
"ram": "",
"nic": "",
"gpu": null
}
}
},
"meta": {}
}Servers
Update server
PATCH
/
servers
/
{server_id}
Python (SDK)
import latitudesh_python_sdk
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.servers.update(server_id="sv_yQrJdNAGO30gv", data={
"id": "sv_yQrJdNAGO30gv",
"type": latitudesh_python_sdk.UpdateServerServersType.SERVERS,
"attributes": {
"project": "proj_yQrJdNMGO30gv",
},
})
# Handle response
print(res)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.Servers.Update(ctx, "sv_yQrJdNAGO30gv", operations.UpdateServerServersRequestBody{
Data: &operations.UpdateServerServersData{
ID: latitudeshgosdk.Pointer("sv_yQrJdNAGO30gv"),
Type: operations.UpdateServerServersTypeServers.ToPointer(),
Attributes: &operations.UpdateServerServersAttributes{
Project: latitudeshgosdk.Pointer("proj_yQrJdNMGO30gv"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Server != nil {
// handle response
}
}import { Latitudesh } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.servers.update({
serverId: "sv_yQrJdNAGO30gv",
requestBody: {
data: {
id: "sv_yQrJdNAGO30gv",
type: "servers",
attributes: {
project: "proj_yQrJdNMGO30gv",
},
},
},
});
console.log(result);
}
run();curl --request PATCH \
--url https://api.latitude.sh/servers/{server_id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"id": "sv_yQrJdNAGO30gv",
"type": "servers",
"attributes": {
"project": "proj_yQrJdNMGO30gv"
}
}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
id: 'sv_yQrJdNAGO30gv',
type: 'servers',
attributes: {project: 'proj_yQrJdNMGO30gv'}
}
})
};
fetch('https://api.latitude.sh/servers/{server_id}', 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.latitude.sh/servers/{server_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'id' => 'sv_yQrJdNAGO30gv',
'type' => 'servers',
'attributes' => [
'project' => 'proj_yQrJdNMGO30gv'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://api.latitude.sh/servers/{server_id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"id\": \"sv_yQrJdNAGO30gv\",\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_yQrJdNMGO30gv\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/servers/{server_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"id\": \"sv_yQrJdNAGO30gv\",\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_yQrJdNMGO30gv\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "sv_yQrJdNAGO30gv",
"type": "servers",
"attributes": {
"tags": [],
"hostname": "Lightweight Wooden Knife",
"label": "136877NODEKM",
"price": 599,
"role": "Bare Metal",
"primary_ipv4": "214.249.69.62",
"primary_ipv6": "b0c8:139:6f83:7f0c:6e2:33a3:78e4:e03f",
"status": "unknown",
"ipmi_status": "Normal",
"created_at": null,
"scheduled_deletion_at": null,
"locked": false,
"rescue_allowed": false,
"region": {
"city": "Frankfurt 115",
"country": "Germany 107",
"site": {
"id": "loc_aNmodjGyqbE8W",
"name": "Frankfurt 115",
"slug": "FRA96",
"facility": "Frankfurt 115",
"rack_id": "rack_byQrJdNJd30gv"
}
},
"team": {
"id": "team_YQZmYB34Nxso86ZgyKj2UEPEnyA",
"name": "348 Team",
"slug": "348-team",
"description": "348 Team",
"address": "51588 Goodwin Mission, Port Oswaldo, KS 14871-0638",
"currency": {
"id": "cur_GnzRD5xAqM5yw",
"code": "agd",
"name": "daznioxpdspfbdbvvikg",
"currency_id": null
},
"status": "verified",
"feature_flags": [],
"limits": {
"bare_metal": 5,
"bare_metal_gpu": 1,
"virtual_machine": 5,
"virtual_machine_gpu": 3,
"elastic_ip": 5,
"virtual_network": 5,
"database": null,
"filesystem": null,
"block_storage": null
}
},
"project": {
"id": "proj_yQrJdNMGO30gv",
"name": "Awesome Wool Computer",
"slug": "awesome-wool-computer",
"description": "Practical Rubber Shirt",
"provisioning_type": "on_demand",
"billing_type": "Normal",
"billing_method": "Normal",
"bandwidth_alert": false,
"environment": null,
"billing": {},
"stats": {
"databases": 0,
"ip_addresses": 0,
"prefixes": 0,
"servers": 1,
"storages": 0,
"virtual_machines": 0,
"vlans": 0
}
},
"plan": {
"id": "plan_3YjJOLLyOvZ87",
"name": "c2.large.arm",
"slug": "c2-large-arm",
"billing": "hourly"
},
"interfaces": [],
"operating_system": {},
"specs": {
"cpu": "",
"disk": "",
"ram": "",
"nic": "",
"gpu": null
}
}
},
"meta": {}
}Authorizations
Path Parameters
Body
application/jsonapplication/vnd.api+json
Show child attributes
Show child attributes
Example:
{
"data": {
"id": "sv_81EVOtR1N4J2Z",
"type": "servers",
"attributes": { "hostname": "new-hostname", "tags": [] }
}
}
Was this page helpful?
⌘I