Kubernetes clusters
List kubernetes cluster namespaces
Returns namespaces for a specific kubernetes cluster for the tenant selected by the X-CostGraph-Tenant-ID header
GET
/
api
/
v1
/
tenant
/
clusters
/
{cluster_id}
/
namespaces
List kubernetes cluster namespaces
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces"
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Authorization": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>', Authorization: '<api-key>'}
};
fetch('https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces', 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.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"items": [
{
"cost_mtd": 123,
"cpu_usage_cores": 123,
"memory_usage_bytes": 123,
"name": "<string>",
"pod_count": 123,
"recommendations": 123,
"estimated_savings": 123
}
],
"limit": 123,
"offset": 123,
"total_count": 123
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Authorizations
Enter "Bearer {token}"
Headers
Tenant ID
Path Parameters
Kubernetes cluster ID
Query Parameters
Cost window: month_to_date, last_7d, last_30d, calendar_month, custom. Default month_to_date
Search by namespace name
Sort field (name, -name, pod_count, -pod_count, cpu_usage_cores, -cpu_usage_cores, memory_usage_bytes, -memory_usage_bytes, estimated_savings, -estimated_savings, cost_mtd, -cost_mtd, recommendations, -recommendations)
Number of rows to return (default 50, max 200)
Rows to skip before returning results (default 0)
Was this page helpful?
⌘I
List kubernetes cluster namespaces
curl --request GET \
--url https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces \
--header 'Authorization: <api-key>' \
--header 'X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>'import requests
url = "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces"
headers = {
"X-CostGraph-Tenant-ID": "<x-costgraph-tenant-id>",
"Authorization": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'X-CostGraph-Tenant-ID': '<x-costgraph-tenant-id>', Authorization: '<api-key>'}
};
fetch('https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces', 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.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"X-CostGraph-Tenant-ID: <x-costgraph-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces")
.header("X-CostGraph-Tenant-ID", "<x-costgraph-tenant-id>")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/tenant/clusters/{cluster_id}/namespaces")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-CostGraph-Tenant-ID"] = '<x-costgraph-tenant-id>'
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"items": [
{
"cost_mtd": 123,
"cpu_usage_cores": 123,
"memory_usage_bytes": 123,
"name": "<string>",
"pod_count": 123,
"recommendations": 123,
"estimated_savings": 123
}
],
"limit": 123,
"offset": 123,
"total_count": 123
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}