curl --request POST \
--url https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"duration_minutes": 60,
"access_level_remote_id": "roles/cloudsql.instanceUser"
}
'import requests
url = "https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}"
payload = {
"duration_minutes": 60,
"access_level_remote_id": "roles/cloudsql.instanceUser"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({duration_minutes: 60, access_level_remote_id: 'roles/cloudsql.instanceUser'})
};
fetch('https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}', 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.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}",
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([
'duration_minutes' => 60,
'access_level_remote_id' => 'roles/cloudsql.instanceUser'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}"
payload := strings.NewReader("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}"
response = http.request(request)
puts response.read_body{
"non_human_identity_id": "29827fb8-f2dd-4e80-9576-28e31e9934ac",
"resource_id": "1b978423-db0a-4037-a4cf-f79c60cb67b3",
"expiration_date": "2022-01-23T04:56:07.000Z"
}Gives a non-human identity access to this resource.
curl --request POST \
--url https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"duration_minutes": 60,
"access_level_remote_id": "roles/cloudsql.instanceUser"
}
'import requests
url = "https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}"
payload = {
"duration_minutes": 60,
"access_level_remote_id": "roles/cloudsql.instanceUser"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({duration_minutes: 60, access_level_remote_id: 'roles/cloudsql.instanceUser'})
};
fetch('https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}', 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.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}",
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([
'duration_minutes' => 60,
'access_level_remote_id' => 'roles/cloudsql.instanceUser'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}"
payload := strings.NewReader("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.opal.dev/v1/resources/{resource_id}/non-human-identities/{non_human_identity_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"duration_minutes\": 60,\n \"access_level_remote_id\": \"roles/cloudsql.instanceUser\"\n}"
response = http.request(request)
puts response.read_body{
"non_human_identity_id": "29827fb8-f2dd-4e80-9576-28e31e9934ac",
"resource_id": "1b978423-db0a-4037-a4cf-f79c60cb67b3",
"expiration_date": "2022-01-23T04:56:07.000Z"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the resource.
The resource ID of the non-human identity to add.
Body
The duration for which the resource can be accessed (in minutes). Use 0 to set to indefinite.
x <= 52596060
The remote ID of the access level to grant. If omitted, the default access level remote ID value (empty string) is used.
"roles/cloudsql.instanceUser"
Response
Details about the access that the non-human identity was granted to the resource.
Resource Non-Human Identity Direct Access Object
Description
This object is used to represent a non-human identity with direct access to a resource.
The ID of the resource.
"1b978423-db0a-4037-a4cf-f79c60cb67b3"
The resource ID of the non-human identity.
"29827fb8-f2dd-4e80-9576-28e31e9934ac"
Access Level Object
Description
The AccessLevel object is used to represent the level of access that a principal has. The "default" access
level is a AccessLevel object whose fields are all empty strings.
Usage Example
View the AccessLevel of a resource/user or resource/group pair to see the level of access granted to the resource.
Show child attributes
Show child attributes
{
"access_level_name": "AdminRole",
"access_level_remote_id": "arn:aws:iam::590304332660:role/AdministratorAccess"
}
The day and time the non-human identity's access will expire.
"2022-01-23T04:56:07.000Z"
Was this page helpful?