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.managed_databases.create_managed_database(data={
"type": latitudesh_python_sdk.ManagedDatabasePayloadType.MANAGED_DATABASES,
"attributes": {
"name": "my-postgres-db",
"project_id": "proj_ABC123",
"region": "ASH",
"plan": "db.psql.small",
"engine": "postgres",
},
})
# Handle response
print(res)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.ManagedDatabases.CreateManagedDatabase(ctx, components.ManagedDatabasePayload{
Data: &components.ManagedDatabasePayloadData{
Type: components.ManagedDatabasePayloadTypeManagedDatabases.ToPointer(),
Attributes: &components.ManagedDatabasePayloadAttributes{
Name: "my-postgres-db",
ProjectID: "proj_ABC123",
Region: "ASH",
Plan: "db.psql.small",
Engine: "postgres",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ManagedDatabase != 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.managedDatabases.createManagedDatabase({
data: {
type: "managed_databases",
attributes: {
name: "my-postgres-db",
projectId: "proj_ABC123",
region: "ASH",
plan: "db.psql.small",
engine: "postgres",
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/managed_databases \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "managed_databases",
"attributes": {
"project_id": "proj_ABC123",
"region": "ASH",
"plan": "db.psql.small",
"engine": "postgres",
"name": "my-postgres-db"
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'managed_databases',
attributes: {
project_id: 'proj_ABC123',
region: 'ASH',
plan: 'db.psql.small',
engine: 'postgres',
name: 'my-postgres-db'
}
}
})
};
fetch('https://api.latitude.sh/managed_databases', 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/managed_databases",
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' => 'managed_databases',
'attributes' => [
'project_id' => 'proj_ABC123',
'region' => 'ASH',
'plan' => 'db.psql.small',
'engine' => 'postgres',
'name' => 'my-postgres-db'
]
]
]),
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/managed_databases")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"managed_databases\",\n \"attributes\": {\n \"project_id\": \"proj_ABC123\",\n \"region\": \"ASH\",\n \"plan\": \"db.psql.small\",\n \"engine\": \"postgres\",\n \"name\": \"my-postgres-db\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/managed_databases")
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\": \"managed_databases\",\n \"attributes\": {\n \"project_id\": \"proj_ABC123\",\n \"region\": \"ASH\",\n \"plan\": \"db.psql.small\",\n \"engine\": \"postgres\",\n \"name\": \"my-postgres-db\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "db_a1b2c3d4",
"type": "managed_databases",
"attributes": {
"name": "<string>",
"engine": "<string>",
"status": "<string>",
"namespace": "<string>",
"created_at": "<string>",
"specs": {
"cpu": 123,
"memory": 123,
"storage": 123,
"shards": 123,
"replicas": 123,
"iops": "<string>"
},
"region": {
"city": "<string>",
"country": "<string>",
"site": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"facility": "<string>"
}
},
"plan": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"billing": "<string>"
},
"team": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"description": "<string>",
"address": "<string>",
"currency": {
"id": "<string>",
"code": "<string>",
"name": "<string>",
"currency_id": 123
},
"status": "<string>",
"feature_flags": [
"<string>"
],
"limits": {
"bare_metal": 123,
"bare_metal_gpu": 123,
"virtual_machine": 123,
"virtual_machine_gpu": 123,
"elastic_ip": 123,
"bgp_session_per_ip": 123,
"public_network": 123,
"virtual_network": 123,
"database": 123,
"filesystem": 123,
"block_storage": 123
}
},
"project": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"description": "<string>",
"billing_type": "<string>",
"provisioning_type": "<string>",
"billing_method": "<string>",
"bandwidth_alert": true,
"environment": "<string>",
"billing": {
"subscription_id": "<string>",
"type": "<string>",
"method": "<string>"
},
"stats": {
"databases": 123,
"ip_addresses": 123,
"prefixes": 123,
"servers": 123,
"storages": 123,
"virtual_machines": 123,
"vlans": 123
}
},
"trusted_sources": [
"<string>"
],
"play_url": "<string>",
"credentials": {
"host": "<string>",
"http_port": 123,
"tcp_port": 123,
"port": 123,
"database": "<string>",
"url": "<string>",
"username": "<string>",
"password": "<string>"
},
"parameters": {},
"pooler": {},
"backup": {},
"recovery": {
"enabled": true
},
"supabase": {
"enabled": true
}
}
}
}Managed Databases
Create a managed database
POST
/
managed_databases
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.managed_databases.create_managed_database(data={
"type": latitudesh_python_sdk.ManagedDatabasePayloadType.MANAGED_DATABASES,
"attributes": {
"name": "my-postgres-db",
"project_id": "proj_ABC123",
"region": "ASH",
"plan": "db.psql.small",
"engine": "postgres",
},
})
# Handle response
print(res)package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.ManagedDatabases.CreateManagedDatabase(ctx, components.ManagedDatabasePayload{
Data: &components.ManagedDatabasePayloadData{
Type: components.ManagedDatabasePayloadTypeManagedDatabases.ToPointer(),
Attributes: &components.ManagedDatabasePayloadAttributes{
Name: "my-postgres-db",
ProjectID: "proj_ABC123",
Region: "ASH",
Plan: "db.psql.small",
Engine: "postgres",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ManagedDatabase != 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.managedDatabases.createManagedDatabase({
data: {
type: "managed_databases",
attributes: {
name: "my-postgres-db",
projectId: "proj_ABC123",
region: "ASH",
plan: "db.psql.small",
engine: "postgres",
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/managed_databases \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "managed_databases",
"attributes": {
"project_id": "proj_ABC123",
"region": "ASH",
"plan": "db.psql.small",
"engine": "postgres",
"name": "my-postgres-db"
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'managed_databases',
attributes: {
project_id: 'proj_ABC123',
region: 'ASH',
plan: 'db.psql.small',
engine: 'postgres',
name: 'my-postgres-db'
}
}
})
};
fetch('https://api.latitude.sh/managed_databases', 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/managed_databases",
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' => 'managed_databases',
'attributes' => [
'project_id' => 'proj_ABC123',
'region' => 'ASH',
'plan' => 'db.psql.small',
'engine' => 'postgres',
'name' => 'my-postgres-db'
]
]
]),
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/managed_databases")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"managed_databases\",\n \"attributes\": {\n \"project_id\": \"proj_ABC123\",\n \"region\": \"ASH\",\n \"plan\": \"db.psql.small\",\n \"engine\": \"postgres\",\n \"name\": \"my-postgres-db\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/managed_databases")
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\": \"managed_databases\",\n \"attributes\": {\n \"project_id\": \"proj_ABC123\",\n \"region\": \"ASH\",\n \"plan\": \"db.psql.small\",\n \"engine\": \"postgres\",\n \"name\": \"my-postgres-db\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "db_a1b2c3d4",
"type": "managed_databases",
"attributes": {
"name": "<string>",
"engine": "<string>",
"status": "<string>",
"namespace": "<string>",
"created_at": "<string>",
"specs": {
"cpu": 123,
"memory": 123,
"storage": 123,
"shards": 123,
"replicas": 123,
"iops": "<string>"
},
"region": {
"city": "<string>",
"country": "<string>",
"site": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"facility": "<string>"
}
},
"plan": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"billing": "<string>"
},
"team": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"description": "<string>",
"address": "<string>",
"currency": {
"id": "<string>",
"code": "<string>",
"name": "<string>",
"currency_id": 123
},
"status": "<string>",
"feature_flags": [
"<string>"
],
"limits": {
"bare_metal": 123,
"bare_metal_gpu": 123,
"virtual_machine": 123,
"virtual_machine_gpu": 123,
"elastic_ip": 123,
"bgp_session_per_ip": 123,
"public_network": 123,
"virtual_network": 123,
"database": 123,
"filesystem": 123,
"block_storage": 123
}
},
"project": {
"id": "<string>",
"name": "<string>",
"slug": "<string>",
"description": "<string>",
"billing_type": "<string>",
"provisioning_type": "<string>",
"billing_method": "<string>",
"bandwidth_alert": true,
"environment": "<string>",
"billing": {
"subscription_id": "<string>",
"type": "<string>",
"method": "<string>"
},
"stats": {
"databases": 123,
"ip_addresses": 123,
"prefixes": 123,
"servers": 123,
"storages": 123,
"virtual_machines": 123,
"vlans": 123
}
},
"trusted_sources": [
"<string>"
],
"play_url": "<string>",
"credentials": {
"host": "<string>",
"http_port": 123,
"tcp_port": 123,
"port": 123,
"database": "<string>",
"url": "<string>",
"username": "<string>",
"password": "<string>"
},
"parameters": {},
"pooler": {},
"backup": {},
"recovery": {
"enabled": true
},
"supabase": {
"enabled": true
}
}
}
}Was this page helpful?