Integrations
Update a PostgreSQL connection
Changes the host, port, database, login or SSL mode of a PostgreSQL connection and checks the new settings the same way connecting does. Leave password empty to keep the stored one; it must be entered again to change the host, port or login. Leave ca_certificate empty to keep the stored one. The instance ID cannot change; connect the other instance instead.
PATCH
/
api
/
v1
/
integrations
/
connections
/
{id}
/
postgres
Update a PostgreSQL connection
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"host": "<string>",
"user": "<string>",
"ca_certificate": "<string>",
"database": "<string>",
"password": "<string>",
"port": 123
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres"
payload = {
"host": "<string>",
"user": "<string>",
"ca_certificate": "<string>",
"database": "<string>",
"password": "<string>",
"port": 123
}
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({
host: '<string>',
user: '<string>',
ca_certificate: '<string>',
database: '<string>',
password: '<string>',
port: 123
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres', 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/connections/{id}/postgres",
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([
'host' => '<string>',
'user' => '<string>',
'ca_certificate' => '<string>',
'database' => '<string>',
'password' => '<string>',
'port' => 123
]),
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/connections/{id}/postgres"
payload := strings.NewReader("{\n \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\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/connections/{id}/postgres")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres")
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 \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"connection": {
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"history": {
"days_remaining": 123,
"window_days": 123,
"loaded_through": "2023-12-25"
},
"hosted": true,
"id": "<string>",
"in_jobs": 123,
"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>",
"sandbox_provider": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"trialing_jobs": 123,
"updated_at": "<string>",
"warnings": [
"<string>"
]
},
"database": "<string>",
"host": "<string>",
"instance_id": "<string>",
"port": 123,
"sslmode": "<string>",
"user": "<string>",
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}Body
application/json
Connection settings
Was this page helpful?
⌘I
Update a PostgreSQL connection
curl --request PATCH \
--url https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"host": "<string>",
"user": "<string>",
"ca_certificate": "<string>",
"database": "<string>",
"password": "<string>",
"port": 123
}
'import requests
url = "https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres"
payload = {
"host": "<string>",
"user": "<string>",
"ca_certificate": "<string>",
"database": "<string>",
"password": "<string>",
"port": 123
}
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({
host: '<string>',
user: '<string>',
ca_certificate: '<string>',
database: '<string>',
password: '<string>',
port: 123
})
};
fetch('https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres', 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/connections/{id}/postgres",
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([
'host' => '<string>',
'user' => '<string>',
'ca_certificate' => '<string>',
'database' => '<string>',
'password' => '<string>',
'port' => 123
]),
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/connections/{id}/postgres"
payload := strings.NewReader("{\n \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\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/connections/{id}/postgres")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.costgraph.ai/api/v1/integrations/connections/{id}/postgres")
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 \"host\": \"<string>\",\n \"user\": \"<string>\",\n \"ca_certificate\": \"<string>\",\n \"database\": \"<string>\",\n \"password\": \"<string>\",\n \"port\": 123\n}"
response = http.request(request)
puts response.read_body{
"message": "some message",
"status": "success",
"data": {
"connection": {
"connection_id": "<string>",
"connection_modes": [
"cost"
],
"created_at": "<string>",
"display_name": "<string>",
"has_metrics_source": true,
"history": {
"days_remaining": 123,
"window_days": 123,
"loaded_through": "2023-12-25"
},
"hosted": true,
"id": "<string>",
"in_jobs": 123,
"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>",
"sandbox_provider": "<string>",
"status": "<string>",
"tenant_id": "<string>",
"trialing_jobs": 123,
"updated_at": "<string>",
"warnings": [
"<string>"
]
},
"database": "<string>",
"host": "<string>",
"instance_id": "<string>",
"port": 123,
"sslmode": "<string>",
"user": "<string>",
"warnings": [
"<string>"
]
}
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}{
"message": "some message",
"status": "error"
}