Choose what a connection is used for
Sets the uses CostGraph may make of a connection: cost reads its bill, metrics reads host metrics through it. Turning metrics off keeps its settings, so turning it on again needs no new setup. Turning metrics on needs the connection to have metrics settings, which a Grafana connection has and a Grafana Cloud cost connection gets through POST /api/v1/integrations/grafana/from-connection/; otherwise it answers 422. Cost cannot be switched off yet: a connection that reads a bill must keep cost, and one that does not cannot add it. A metrics-only Grafana connection accepts only metrics. At least one use must be chosen. The caller must be an organization owner, admin or billing admin.
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/{id}/modes \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"connection_modes": []
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/{id}/modes"
payload = { "connection_modes": [] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({connection_modes: []})
};
fetch('https://api.costgraph.ai/api/v1/integrations/{id}/modes', 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/integrations/{id}/modes",
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([
'connection_modes' => [
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/integrations/{id}/modes"
payload := strings.NewReader("{\n \"connection_modes\": []\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.costgraph.ai/api/v1/integrations/{id}/modes")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"connection_modes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/{id}/modes")
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 \"connection_modes\": []\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"ci_history": {
"days_loaded": 123,
"days_total": 123
},
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"id": "<string>",
"ingest_mode": "pull",
"last_sync_error": "<string>",
"last_synced_at": "<string>",
"needs_service_token": true,
"provider": "<string>",
"provider_account_id": "<string>",
"recommendations_checked_at": "<string>",
"recommendations_status": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"updated_at": "<string>",
"warnings": [
"<string>"
]
}
}{
"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}"
Path Parameters
Connection id from the id field of the connection list, not the fpc_ connection_id
Body
Connection uses
1cost, metrics Was this page helpful?
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/{id}/modes \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"connection_modes": []
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/{id}/modes"
payload = { "connection_modes": [] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({connection_modes: []})
};
fetch('https://api.costgraph.ai/api/v1/integrations/{id}/modes', 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/integrations/{id}/modes",
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([
'connection_modes' => [
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.costgraph.ai/api/v1/integrations/{id}/modes"
payload := strings.NewReader("{\n \"connection_modes\": []\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.costgraph.ai/api/v1/integrations/{id}/modes")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"connection_modes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/{id}/modes")
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 \"connection_modes\": []\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"ci_history": {
"days_loaded": 123,
"days_total": 123
},
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"id": "<string>",
"ingest_mode": "pull",
"last_sync_error": "<string>",
"last_synced_at": "<string>",
"needs_service_token": true,
"provider": "<string>",
"provider_account_id": "<string>",
"recommendations_checked_at": "<string>",
"recommendations_status": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"updated_at": "<string>",
"warnings": [
"<string>"
]
}
}{
"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"
}