curl --request POST \
--url https://use.hoop.dev/api/resources/{name}/plan \
--header 'Content-Type: application/json' \
--data '
{
"privileges": [
"SELECT",
"INSERT"
],
"role": "ro",
"scopes": [
"mydb",
"otherdb.public"
],
"type": "managed",
"resource_name": "my-postgres",
"rotate_password": false,
"source_role": "pg_read_all_data"
}
'import requests
url = "https://use.hoop.dev/api/resources/{name}/plan"
payload = {
"privileges": ["SELECT", "INSERT"],
"role": "ro",
"scopes": ["mydb", "otherdb.public"],
"type": "managed",
"resource_name": "my-postgres",
"rotate_password": False,
"source_role": "pg_read_all_data"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
privileges: ['SELECT', 'INSERT'],
role: 'ro',
scopes: ['mydb', 'otherdb.public'],
type: 'managed',
resource_name: 'my-postgres',
rotate_password: false,
source_role: 'pg_read_all_data'
})
};
fetch('https://use.hoop.dev/api/resources/{name}/plan', 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://use.hoop.dev/api/resources/{name}/plan",
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([
'privileges' => [
'SELECT',
'INSERT'
],
'role' => 'ro',
'scopes' => [
'mydb',
'otherdb.public'
],
'type' => 'managed',
'resource_name' => 'my-postgres',
'rotate_password' => false,
'source_role' => 'pg_read_all_data'
]),
CURLOPT_HTTPHEADER => [
"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://use.hoop.dev/api/resources/{name}/plan"
payload := strings.NewReader("{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.post("https://use.hoop.dev/api/resources/{name}/plan")
.header("Content-Type", "application/json")
.body("{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources/{name}/plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}"
response = http.request(request)
puts response.read_body{
"message": "failed retrieving resource: connection refused",
"resource_name": "my-postgres",
"role": "hoopdev_my_postgres_ro_ab3c1f7e",
"sid": "5701046A-7B7A-4A78-ABB0-A24C95E6FE54",
"status": "success"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Creates a resource plan
Validates a provisioning plan for a single resource by computing the diff between the desired and current role state. The plan is session-audited and returns a plan ID (SID) that can be referenced when applying.
curl --request POST \
--url https://use.hoop.dev/api/resources/{name}/plan \
--header 'Content-Type: application/json' \
--data '
{
"privileges": [
"SELECT",
"INSERT"
],
"role": "ro",
"scopes": [
"mydb",
"otherdb.public"
],
"type": "managed",
"resource_name": "my-postgres",
"rotate_password": false,
"source_role": "pg_read_all_data"
}
'import requests
url = "https://use.hoop.dev/api/resources/{name}/plan"
payload = {
"privileges": ["SELECT", "INSERT"],
"role": "ro",
"scopes": ["mydb", "otherdb.public"],
"type": "managed",
"resource_name": "my-postgres",
"rotate_password": False,
"source_role": "pg_read_all_data"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
privileges: ['SELECT', 'INSERT'],
role: 'ro',
scopes: ['mydb', 'otherdb.public'],
type: 'managed',
resource_name: 'my-postgres',
rotate_password: false,
source_role: 'pg_read_all_data'
})
};
fetch('https://use.hoop.dev/api/resources/{name}/plan', 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://use.hoop.dev/api/resources/{name}/plan",
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([
'privileges' => [
'SELECT',
'INSERT'
],
'role' => 'ro',
'scopes' => [
'mydb',
'otherdb.public'
],
'type' => 'managed',
'resource_name' => 'my-postgres',
'rotate_password' => false,
'source_role' => 'pg_read_all_data'
]),
CURLOPT_HTTPHEADER => [
"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://use.hoop.dev/api/resources/{name}/plan"
payload := strings.NewReader("{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.post("https://use.hoop.dev/api/resources/{name}/plan")
.header("Content-Type", "application/json")
.body("{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources/{name}/plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"privileges\": [\n \"SELECT\",\n \"INSERT\"\n ],\n \"role\": \"ro\",\n \"scopes\": [\n \"mydb\",\n \"otherdb.public\"\n ],\n \"type\": \"managed\",\n \"resource_name\": \"my-postgres\",\n \"rotate_password\": false,\n \"source_role\": \"pg_read_all_data\"\n}"
response = http.request(request)
puts response.read_body{
"message": "failed retrieving resource: connection refused",
"resource_name": "my-postgres",
"role": "hoopdev_my_postgres_ro_ab3c1f7e",
"sid": "5701046A-7B7A-4A78-ABB0-A24C95E6FE54",
"status": "success"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Path Parameters
The resource name
Body
The request body
The list of privileges to grant on all tables in each scope. Supported values: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, EXECUTE.
["SELECT", "INSERT"]
A short label used to derive the generated postgres role name (e.g. "ro", "rw", "analyst"). The actual role created in postgres is a deterministic slug of the form hoopdev_.
"ro"
The list of databases and schemas to apply privileges to, formatted as "database" or "database.schema". If the schema is omitted, privileges are applied to the public schema of that database.
["mydb", "otherdb.public"]
Role management mode. "managed" creates and fully owns the postgres role (password managed by hoop). "external" attaches the role as a member of an existing parent role specified by source_role.
managed, external "managed"
The resource name to plan provisioning for. Required for batch requests.
"my-postgres"
When true, rotates the role's password on this plan run. Only takes effect if the role already exists; new roles always receive a freshly generated password regardless of this flag.
false
An existing postgres role whose privileges the new role will inherit via membership. Only relevant when type is "external"; ignored for "managed".
"pg_read_all_data"
Response
OK
Error message populated when status is "failed"; empty on success
"failed retrieving resource: connection refused"
The resource name this plan result is for
"my-postgres"
The generated postgres role name derived from the resource name and role label (format: hoopdev_<8-char-hash>).
"hoopdev_my_postgres_ro_ab3c1f7e"
The session ID for tracking and auditing this plan execution
"5701046A-7B7A-4A78-ABB0-A24C95E6FE54"
Status of the plan execution
success, failed "success"
Was this page helpful?