Go (SDK)
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.Clusters.CreateProjectClusterNodeGroup(ctx, "proj_lxWpD699qm6rk", components.CreateClusterNodeGroup{
Data: components.CreateClusterNodeGroupData{
Type: components.CreateClusterNodeGroupTypeClusterNodeGroups,
Attributes: components.CreateClusterNodeGroupAttributes{
Name: "login",
Kind: components.CreateClusterNodeGroupKindCPU,
Plan: "g4-b300-large",
ServerCount: 2,
Os: latitudeshgosdk.Pointer("rocky_9_x64"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ClusterNodeGroup != 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.clusters.createProjectClusterNodeGroup({
projectId: "proj_lxWpD699qm6rk",
createClusterNodeGroup: {
data: {
type: "cluster_node_groups",
attributes: {
name: "login",
kind: "cpu",
plan: "g4-b300-large",
serverCount: 2,
os: "rocky_9_x64",
},
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/projects/{project_id}/cluster/node_groups \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"server_count": 2,
"os": "rocky_9_x64"
}
}
}
'import requests
url = "https://api.latitude.sh/projects/{project_id}/cluster/node_groups"
payload = { "data": {
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"server_count": 2,
"os": "rocky_9_x64"
}
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'cluster_node_groups',
attributes: {
name: 'login',
kind: 'cpu',
plan: 'g4-b300-large',
server_count: 2,
os: 'rocky_9_x64'
}
}
})
};
fetch('https://api.latitude.sh/projects/{project_id}/cluster/node_groups', 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/projects/{project_id}/cluster/node_groups",
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' => 'cluster_node_groups',
'attributes' => [
'name' => 'login',
'kind' => 'cpu',
'plan' => 'g4-b300-large',
'server_count' => 2,
'os' => 'rocky_9_x64'
]
]
]),
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/projects/{project_id}/cluster/node_groups")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"cluster_node_groups\",\n \"attributes\": {\n \"name\": \"login\",\n \"kind\": \"cpu\",\n \"plan\": \"g4-b300-large\",\n \"server_count\": 2,\n \"os\": \"rocky_9_x64\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/projects/{project_id}/cluster/node_groups")
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\": \"cluster_node_groups\",\n \"attributes\": {\n \"name\": \"login\",\n \"kind\": \"cpu\",\n \"plan\": \"g4-b300-large\",\n \"server_count\": 2,\n \"os\": \"rocky_9_x64\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "8",
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"plan_name": "g4.b300.large",
"server_count": 2,
"os": "rocky_9_x64"
}
}
}{
"errors": [
{
"code": "PROJECT_NOT_A_CLUSTER",
"title": "Project Not A Cluster",
"detail": "This project is not a cluster",
"status": "404",
"meta": {}
}
]
}{
"errors": [
{
"code": "REQUIREMENTS_NOT_EDITABLE",
"title": "Requirements Not Editable",
"detail": "These requirements are not ready for your review yet",
"status": "409",
"meta": {}
}
]
}{
"errors": [
{
"code": "VALIDATION_ERROR",
"title": "Validation Error",
"detail": "windows_2022 is not an operating system this node group's plan can run",
"status": "422",
"meta": {}
}
]
}Clusters
Create a cluster node group
Adds a node group to your cluster. Only available for projects that have a GPU cluster; any other project answers 404 PROJECT_NOT_A_CLUSTER. Signed requirements need to be signed again. Needs an owner, administrator or collaborator.
POST
/
projects
/
{project_id}
/
cluster
/
node_groups
Go (SDK)
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.Clusters.CreateProjectClusterNodeGroup(ctx, "proj_lxWpD699qm6rk", components.CreateClusterNodeGroup{
Data: components.CreateClusterNodeGroupData{
Type: components.CreateClusterNodeGroupTypeClusterNodeGroups,
Attributes: components.CreateClusterNodeGroupAttributes{
Name: "login",
Kind: components.CreateClusterNodeGroupKindCPU,
Plan: "g4-b300-large",
ServerCount: 2,
Os: latitudeshgosdk.Pointer("rocky_9_x64"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.ClusterNodeGroup != 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.clusters.createProjectClusterNodeGroup({
projectId: "proj_lxWpD699qm6rk",
createClusterNodeGroup: {
data: {
type: "cluster_node_groups",
attributes: {
name: "login",
kind: "cpu",
plan: "g4-b300-large",
serverCount: 2,
os: "rocky_9_x64",
},
},
},
});
console.log(result);
}
run();curl --request POST \
--url https://api.latitude.sh/projects/{project_id}/cluster/node_groups \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"server_count": 2,
"os": "rocky_9_x64"
}
}
}
'import requests
url = "https://api.latitude.sh/projects/{project_id}/cluster/node_groups"
payload = { "data": {
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"server_count": 2,
"os": "rocky_9_x64"
}
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
type: 'cluster_node_groups',
attributes: {
name: 'login',
kind: 'cpu',
plan: 'g4-b300-large',
server_count: 2,
os: 'rocky_9_x64'
}
}
})
};
fetch('https://api.latitude.sh/projects/{project_id}/cluster/node_groups', 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/projects/{project_id}/cluster/node_groups",
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' => 'cluster_node_groups',
'attributes' => [
'name' => 'login',
'kind' => 'cpu',
'plan' => 'g4-b300-large',
'server_count' => 2,
'os' => 'rocky_9_x64'
]
]
]),
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/projects/{project_id}/cluster/node_groups")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"cluster_node_groups\",\n \"attributes\": {\n \"name\": \"login\",\n \"kind\": \"cpu\",\n \"plan\": \"g4-b300-large\",\n \"server_count\": 2,\n \"os\": \"rocky_9_x64\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/projects/{project_id}/cluster/node_groups")
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\": \"cluster_node_groups\",\n \"attributes\": {\n \"name\": \"login\",\n \"kind\": \"cpu\",\n \"plan\": \"g4-b300-large\",\n \"server_count\": 2,\n \"os\": \"rocky_9_x64\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "8",
"type": "cluster_node_groups",
"attributes": {
"name": "login",
"kind": "cpu",
"plan": "g4-b300-large",
"plan_name": "g4.b300.large",
"server_count": 2,
"os": "rocky_9_x64"
}
}
}{
"errors": [
{
"code": "PROJECT_NOT_A_CLUSTER",
"title": "Project Not A Cluster",
"detail": "This project is not a cluster",
"status": "404",
"meta": {}
}
]
}{
"errors": [
{
"code": "REQUIREMENTS_NOT_EDITABLE",
"title": "Requirements Not Editable",
"detail": "These requirements are not ready for your review yet",
"status": "409",
"meta": {}
}
]
}{
"errors": [
{
"code": "VALIDATION_ERROR",
"title": "Validation Error",
"detail": "windows_2022 is not an operating system this node group's plan can run",
"status": "422",
"meta": {}
}
]
}Was this page helpful?