curl --request POST \
--url https://use.hoop.dev/api/resources \
--header 'Content-Type: */*' \
--data '
{
"env_vars": {},
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"command": [
"/bin/bash"
],
"secret": {},
"subtype": "postgres"
}
]
}
'import requests
url = "https://use.hoop.dev/api/resources"
payload = {
"env_vars": {},
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"command": ["/bin/bash"],
"secret": {},
"subtype": "postgres"
}
]
}
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify({
env_vars: {},
name: 'my-resource',
subtype: 'mysql',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
roles: [
{
name: 'pgdemo',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
command: ['/bin/bash'],
secret: {},
subtype: 'postgres'
}
]
})
};
fetch('https://use.hoop.dev/api/resources', 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",
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([
'env_vars' => [
],
'name' => 'my-resource',
'subtype' => 'mysql',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'roles' => [
[
'name' => 'pgdemo',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'command' => [
'/bin/bash'
],
'secret' => [
],
'subtype' => 'postgres'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$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"
payload := strings.NewReader("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
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")
.header("Content-Type", "*/*")
.body("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"created_at": "2024-07-25T15:56:35.317601Z",
"env_vars": {},
"id": "15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7",
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"updated_at": "2024-07-25T15:56:35.317601Z"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Creates a resource
Creates a resource for the organization.
curl --request POST \
--url https://use.hoop.dev/api/resources \
--header 'Content-Type: */*' \
--data '
{
"env_vars": {},
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"command": [
"/bin/bash"
],
"secret": {},
"subtype": "postgres"
}
]
}
'import requests
url = "https://use.hoop.dev/api/resources"
payload = {
"env_vars": {},
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"roles": [
{
"name": "pgdemo",
"type": "database",
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"command": ["/bin/bash"],
"secret": {},
"subtype": "postgres"
}
]
}
headers = {"Content-Type": "*/*"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '*/*'},
body: JSON.stringify({
env_vars: {},
name: 'my-resource',
subtype: 'mysql',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
roles: [
{
name: 'pgdemo',
type: 'database',
agent_id: '1837453e-01fc-46f3-9e4c-dcf22d395393',
command: ['/bin/bash'],
secret: {},
subtype: 'postgres'
}
]
})
};
fetch('https://use.hoop.dev/api/resources', 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",
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([
'env_vars' => [
],
'name' => 'my-resource',
'subtype' => 'mysql',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'roles' => [
[
'name' => 'pgdemo',
'type' => 'database',
'agent_id' => '1837453e-01fc-46f3-9e4c-dcf22d395393',
'command' => [
'/bin/bash'
],
'secret' => [
],
'subtype' => 'postgres'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: */*"
],
]);
$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"
payload := strings.NewReader("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "*/*")
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")
.header("Content-Type", "*/*")
.body("{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://use.hoop.dev/api/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '*/*'
request.body = "{\n \"env_vars\": {},\n \"name\": \"my-resource\",\n \"subtype\": \"mysql\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"roles\": [\n {\n \"name\": \"pgdemo\",\n \"type\": \"database\",\n \"agent_id\": \"1837453e-01fc-46f3-9e4c-dcf22d395393\",\n \"command\": [\n \"/bin/bash\"\n ],\n \"secret\": {},\n \"subtype\": \"postgres\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "1837453e-01fc-46f3-9e4c-dcf22d395393",
"created_at": "2024-07-25T15:56:35.317601Z",
"env_vars": {},
"id": "15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7",
"name": "my-resource",
"subtype": "mysql",
"type": "database",
"updated_at": "2024-07-25T15:56:35.317601Z"
}{
"message": "the error description"
}{
"message": "the error description"
}{
"message": "the error description"
}Body
The request body resource
The resource environment variables
Show child attributes
Show child attributes
The resource name
"my-resource"
The resource subtype
"mysql"
The resource type
"database"
The agent associated with this resource
"1837453e-01fc-46f3-9e4c-dcf22d395393"
The roles associated with this resource
Show child attributes
Show child attributes
Response
Created
The agent associated with this resource
"1837453e-01fc-46f3-9e4c-dcf22d395393"
The time the resource was created
"2024-07-25T15:56:35.317601Z"
The resource environment variables
Show child attributes
Show child attributes
The resource ID
"15B5A2FD-0706-4A47-B1CF-B93CCFC5B3D7"
The resource name
"my-resource"
The resource subtype
"mysql"
The resource type
"database"
The time the resource was updated
"2024-07-25T15:56:35.317601Z"
Was this page helpful?