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.create(data={
"type": latitudesh_python_sdk.CreateServerServersType.SERVERS,
"attributes": {
"project": "proj_lxWpD699qm6rk",
"plan": latitudesh_python_sdk.CreateServerServersPlan.C2_SMALL_X86,
"site": latitudesh_python_sdk.CreateServerServersSite.ASH,
"operating_system": latitudesh_python_sdk.CreateServerServersOperatingSystem.UBUNTU_22_04_X64_LTS,
"hostname": "BRC1",
},
})
# 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.Create(ctx, operations.CreateServerServersRequestBody{
Data: &operations.CreateServerServersData{
Type: operations.CreateServerServersTypeServers,
Attributes: &operations.CreateServerServersAttributes{
Project: latitudeshgosdk.Pointer("proj_lxWpD699qm6rk"),
Plan: operations.CreateServerPlanC2SmallX86.ToPointer(),
Site: operations.CreateServerSiteAsh.ToPointer(),
OperatingSystem: operations.CreateServerOperatingSystemUbuntu2204X64Lts.ToPointer(),
Hostname: latitudeshgosdk.Pointer("BRC1"),
},
},
})
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.create({
data: {
type: "servers",
attributes: {
project: "proj_lxWpD699qm6rk",
plan: "c2-small-x86",
site: "ASH",
operatingSystem: "ubuntu_22_04_x64_lts",
hostname: "BRC1",
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/servers \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "servers",
"attributes": {
"project": "proj_lxWpD699qm6rk",
"plan": "c2-small-x86",
"site": "ASH",
"operating_system": "ubuntu_22_04_x64_lts",
"hostname": "BRC1"
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'servers',
attributes: {
project: 'proj_lxWpD699qm6rk',
plan: 'c2-small-x86',
site: 'ASH',
operating_system: 'ubuntu_22_04_x64_lts',
hostname: 'BRC1'
}
}
})
};
fetch('https://api.latitude.sh/servers', 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",
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([
'data' => [
'type' => 'servers',
'attributes' => [
'project' => 'proj_lxWpD699qm6rk',
'plan' => 'c2-small-x86',
'site' => 'ASH',
'operating_system' => 'ubuntu_22_04_x64_lts',
'hostname' => 'BRC1'
]
]
]),
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.post("https://api.latitude.sh/servers")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_lxWpD699qm6rk\",\n \"plan\": \"c2-small-x86\",\n \"site\": \"ASH\",\n \"operating_system\": \"ubuntu_22_04_x64_lts\",\n \"hostname\": \"BRC1\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/servers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_lxWpD699qm6rk\",\n \"plan\": \"c2-small-x86\",\n \"site\": \"ASH\",\n \"operating_system\": \"ubuntu_22_04_x64_lts\",\n \"hostname\": \"BRC1\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "servers",
"id": "sv_W6Q2D9xGqKLpr",
"attributes": {
"hostname": "BRC1",
"label": "846419NODEME",
"role": "Bare Metal",
"status": "off",
"primary_ipv4": "171.189.35.253",
"primary_ipv6": "7d69:748d:26cc:796a:1248:b6be:a658:96a4",
"specs": {
"cpu": "Xeon E-2186G CPU @ 3.80GHz (6 cores)",
"disk": "500 GB SSD",
"ram": "32 GB",
"nic": ""
},
"plan": {
"id": "plan_8NkvdyMKdeLpx",
"name": "c2.small.x86",
"slug": "c2-small-x86",
"billing": "hourly"
},
"interfaces": [
{
"role": "ipmi",
"name": "IPMI",
"mac_address": "00:11:22:33:44:55",
"description": "IPMI Interface"
},
{
"role": "internal",
"name": "PXE",
"mac_address": "66:77:88:99:aa:bb",
"description": "PXE Interface"
},
{
"role": "unknown",
"name": "PO1",
"mac_address": null,
"description": "LAG interface (no associated MAC record)"
}
]
}
},
"meta": {}
}Servers
Create server
POST
/
servers
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.create(data={
"type": latitudesh_python_sdk.CreateServerServersType.SERVERS,
"attributes": {
"project": "proj_lxWpD699qm6rk",
"plan": latitudesh_python_sdk.CreateServerServersPlan.C2_SMALL_X86,
"site": latitudesh_python_sdk.CreateServerServersSite.ASH,
"operating_system": latitudesh_python_sdk.CreateServerServersOperatingSystem.UBUNTU_22_04_X64_LTS,
"hostname": "BRC1",
},
})
# 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.Create(ctx, operations.CreateServerServersRequestBody{
Data: &operations.CreateServerServersData{
Type: operations.CreateServerServersTypeServers,
Attributes: &operations.CreateServerServersAttributes{
Project: latitudeshgosdk.Pointer("proj_lxWpD699qm6rk"),
Plan: operations.CreateServerPlanC2SmallX86.ToPointer(),
Site: operations.CreateServerSiteAsh.ToPointer(),
OperatingSystem: operations.CreateServerOperatingSystemUbuntu2204X64Lts.ToPointer(),
Hostname: latitudeshgosdk.Pointer("BRC1"),
},
},
})
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.create({
data: {
type: "servers",
attributes: {
project: "proj_lxWpD699qm6rk",
plan: "c2-small-x86",
site: "ASH",
operatingSystem: "ubuntu_22_04_x64_lts",
hostname: "BRC1",
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/servers \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "servers",
"attributes": {
"project": "proj_lxWpD699qm6rk",
"plan": "c2-small-x86",
"site": "ASH",
"operating_system": "ubuntu_22_04_x64_lts",
"hostname": "BRC1"
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'servers',
attributes: {
project: 'proj_lxWpD699qm6rk',
plan: 'c2-small-x86',
site: 'ASH',
operating_system: 'ubuntu_22_04_x64_lts',
hostname: 'BRC1'
}
}
})
};
fetch('https://api.latitude.sh/servers', 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",
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([
'data' => [
'type' => 'servers',
'attributes' => [
'project' => 'proj_lxWpD699qm6rk',
'plan' => 'c2-small-x86',
'site' => 'ASH',
'operating_system' => 'ubuntu_22_04_x64_lts',
'hostname' => 'BRC1'
]
]
]),
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.post("https://api.latitude.sh/servers")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_lxWpD699qm6rk\",\n \"plan\": \"c2-small-x86\",\n \"site\": \"ASH\",\n \"operating_system\": \"ubuntu_22_04_x64_lts\",\n \"hostname\": \"BRC1\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/servers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"type\": \"servers\",\n \"attributes\": {\n \"project\": \"proj_lxWpD699qm6rk\",\n \"plan\": \"c2-small-x86\",\n \"site\": \"ASH\",\n \"operating_system\": \"ubuntu_22_04_x64_lts\",\n \"hostname\": \"BRC1\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "servers",
"id": "sv_W6Q2D9xGqKLpr",
"attributes": {
"hostname": "BRC1",
"label": "846419NODEME",
"role": "Bare Metal",
"status": "off",
"primary_ipv4": "171.189.35.253",
"primary_ipv6": "7d69:748d:26cc:796a:1248:b6be:a658:96a4",
"specs": {
"cpu": "Xeon E-2186G CPU @ 3.80GHz (6 cores)",
"disk": "500 GB SSD",
"ram": "32 GB",
"nic": ""
},
"plan": {
"id": "plan_8NkvdyMKdeLpx",
"name": "c2.small.x86",
"slug": "c2-small-x86",
"billing": "hourly"
},
"interfaces": [
{
"role": "ipmi",
"name": "IPMI",
"mac_address": "00:11:22:33:44:55",
"description": "IPMI Interface"
},
{
"role": "internal",
"name": "PXE",
"mac_address": "66:77:88:99:aa:bb",
"description": "PXE Interface"
},
{
"role": "unknown",
"name": "PO1",
"mac_address": null,
"description": "LAG interface (no associated MAC record)"
}
]
}
},
"meta": {}
}Was this page helpful?
⌘I