cURL
curl --request POST \
--url https://api.osohq.com/api/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"inserts": [
{
"predicate": "<string>",
"args": [
{
"type": "<string>",
"id": "<string>"
}
]
}
]
}
]
'import os
from oso_cloud import Oso, Value
oso = Oso(api_key=os.environ.get('OSO_CLOUD_API_KEY', None))
# Batch multiple operations
user = Value("User", "alice")
org = Value("Organization", "acme")
repo = Value("Repository", "anvils")
with oso.batch() as tx:
# Insert new facts
tx.insert(("has_role", user, "owner", org))
tx.insert(("has_permission", user, "admin", repo))
# Delete old facts
tx.delete(("has_role", user, "maintainer", repo))
tx.delete(("has_role", user, "member", org))import { Oso } from 'oso-cloud';
const apiKey = process.env.OSO_CLOUD_API_KEY;
const oso = new Oso("https://cloud.osohq.com", apiKey);
// Batch multiple operations
const user = { type: "User", id: "alice" };
const org = { type: "Organization", id: "acme" };
const repo = { type: "Repository", id: "anvils" };
await oso.batch((tx) => {
// Insert new facts
tx.insert(["has_role", user, "owner", org]);
tx.insert(["has_permission", user, "admin", repo]);
// Delete old facts
tx.delete(["has_role", user, "maintainer", repo]);
tx.delete(["has_role", user, "member", org]);
});package main
import (
"log"
"os"
oso "github.com/osohq/go-oso-cloud/v2"
)
func main() {
apiKey := os.Getenv("OSO_CLOUD_API_KEY")
osoClient := oso.NewClient("https://cloud.osohq.com", apiKey)
// Batch multiple operations
user := oso.NewValue("User", "alice")
org := oso.NewValue("Organization", "acme")
repo := oso.NewValue("Repository", "anvils")
err := osoClient.Batch(func(tx oso.BatchTransaction) {
// Insert new facts
tx.Insert(oso.NewFact("has_role", user, oso.String("owner"), org))
tx.Insert(oso.NewFact("has_permission", user, oso.String("admin"), repo))
// Delete old facts
tx.Delete(oso.NewFact("has_role", user, oso.String("maintainer"), repo))
tx.Delete(oso.NewFactPattern("has_role", user, nil, org))
})
if err != nil {
log.Fatal(err)
}
}package com.mycompany;
import java.io.IOException;
import com.osohq.oso_cloud.Oso;
import com.osohq.oso_cloud.api.ApiException;
import com.osohq.oso_cloud.api.Value;
public class App {
public static void main(String[] args) {
String apiKey = System.getenv("OSO_CLOUD_API_KEY");
Oso oso = new Oso(apiKey);
try {
// Batch multiple operations
Value user = new Value("User", "alice");
Value org = new Value("Organization", "acme");
Value repo = new Value("Repository", "anvils");
oso.batch((tx) -> {
// Insert new facts
tx.insert("has_role", user, "owner", org);
tx.insert("has_permission", user, "admin", repo);
// Delete old facts
tx.delete("has_role", user, "maintainer", repo);
tx.delete("has_role", user, "member", org);
});
} catch (IOException | ApiException e) {
System.err.println("Error: " + e.getMessage());
}
}
}require 'oso-cloud'
api_key = ENV.fetch('OSO_CLOUD_API_KEY', nil)
oso = OsoCloud::Oso.new(url: "https://cloud.osohq.com", api_key: api_key)
# Batch multiple operations
user = OsoCloud::Value.new(type: "User", id: "alice")
org = OsoCloud::Value.new(type: "Organization", id: "acme")
repo = OsoCloud::Value.new(type: "Repository", id: "anvils")
oso.batch do |tx|
# Insert new facts
tx.tell("has_role", user, "owner", org)
tx.tell("has_permission", user, "admin", repo)
# Delete old facts
tx.delete("has_role", user, "maintainer", repo)
tx.delete("has_role", user, "member", org)
endusing OsoCloud;
string? apiKey = Environment.GetEnvironmentVariable("OSO_CLOUD_API_KEY");
var oso = new Oso("https://api.osohq.com", apiKey);
// Batch multiple operations
var user = new Value("User", "alice");
var org = new Value("Organization", "acme");
var repo = new Value("Repository", "anvils");
await oso.Batch(tx => {
// Insert new facts
tx.Insert("has_role", user, "owner", org);
tx.Insert("has_permission", user, "admin", repo);
// Delete old facts
tx.Delete("has_role", user, "maintainer", repo);
tx.Delete("has_role", user, "member", org);
});{
"message": "<string>"
}{
"message": "<string>"
}Centralized Authorization Data
Post batch
Deletes and adds many facts in one atomic batch. Facts are inserted and deleted in-order (ie: inserted facts may be deleted in the same transaction). null can be used as a wildcard in deleted facts. Does not throw an error when the facts to delete are not found.
POST
/
batch
cURL
curl --request POST \
--url https://api.osohq.com/api/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"inserts": [
{
"predicate": "<string>",
"args": [
{
"type": "<string>",
"id": "<string>"
}
]
}
]
}
]
'import os
from oso_cloud import Oso, Value
oso = Oso(api_key=os.environ.get('OSO_CLOUD_API_KEY', None))
# Batch multiple operations
user = Value("User", "alice")
org = Value("Organization", "acme")
repo = Value("Repository", "anvils")
with oso.batch() as tx:
# Insert new facts
tx.insert(("has_role", user, "owner", org))
tx.insert(("has_permission", user, "admin", repo))
# Delete old facts
tx.delete(("has_role", user, "maintainer", repo))
tx.delete(("has_role", user, "member", org))import { Oso } from 'oso-cloud';
const apiKey = process.env.OSO_CLOUD_API_KEY;
const oso = new Oso("https://cloud.osohq.com", apiKey);
// Batch multiple operations
const user = { type: "User", id: "alice" };
const org = { type: "Organization", id: "acme" };
const repo = { type: "Repository", id: "anvils" };
await oso.batch((tx) => {
// Insert new facts
tx.insert(["has_role", user, "owner", org]);
tx.insert(["has_permission", user, "admin", repo]);
// Delete old facts
tx.delete(["has_role", user, "maintainer", repo]);
tx.delete(["has_role", user, "member", org]);
});package main
import (
"log"
"os"
oso "github.com/osohq/go-oso-cloud/v2"
)
func main() {
apiKey := os.Getenv("OSO_CLOUD_API_KEY")
osoClient := oso.NewClient("https://cloud.osohq.com", apiKey)
// Batch multiple operations
user := oso.NewValue("User", "alice")
org := oso.NewValue("Organization", "acme")
repo := oso.NewValue("Repository", "anvils")
err := osoClient.Batch(func(tx oso.BatchTransaction) {
// Insert new facts
tx.Insert(oso.NewFact("has_role", user, oso.String("owner"), org))
tx.Insert(oso.NewFact("has_permission", user, oso.String("admin"), repo))
// Delete old facts
tx.Delete(oso.NewFact("has_role", user, oso.String("maintainer"), repo))
tx.Delete(oso.NewFactPattern("has_role", user, nil, org))
})
if err != nil {
log.Fatal(err)
}
}package com.mycompany;
import java.io.IOException;
import com.osohq.oso_cloud.Oso;
import com.osohq.oso_cloud.api.ApiException;
import com.osohq.oso_cloud.api.Value;
public class App {
public static void main(String[] args) {
String apiKey = System.getenv("OSO_CLOUD_API_KEY");
Oso oso = new Oso(apiKey);
try {
// Batch multiple operations
Value user = new Value("User", "alice");
Value org = new Value("Organization", "acme");
Value repo = new Value("Repository", "anvils");
oso.batch((tx) -> {
// Insert new facts
tx.insert("has_role", user, "owner", org);
tx.insert("has_permission", user, "admin", repo);
// Delete old facts
tx.delete("has_role", user, "maintainer", repo);
tx.delete("has_role", user, "member", org);
});
} catch (IOException | ApiException e) {
System.err.println("Error: " + e.getMessage());
}
}
}require 'oso-cloud'
api_key = ENV.fetch('OSO_CLOUD_API_KEY', nil)
oso = OsoCloud::Oso.new(url: "https://cloud.osohq.com", api_key: api_key)
# Batch multiple operations
user = OsoCloud::Value.new(type: "User", id: "alice")
org = OsoCloud::Value.new(type: "Organization", id: "acme")
repo = OsoCloud::Value.new(type: "Repository", id: "anvils")
oso.batch do |tx|
# Insert new facts
tx.tell("has_role", user, "owner", org)
tx.tell("has_permission", user, "admin", repo)
# Delete old facts
tx.delete("has_role", user, "maintainer", repo)
tx.delete("has_role", user, "member", org)
endusing OsoCloud;
string? apiKey = Environment.GetEnvironmentVariable("OSO_CLOUD_API_KEY");
var oso = new Oso("https://api.osohq.com", apiKey);
// Batch multiple operations
var user = new Value("User", "alice");
var org = new Value("Organization", "acme");
var repo = new Value("Repository", "anvils");
await oso.Batch(tx => {
// Insert new facts
tx.Insert("has_role", user, "owner", org);
tx.Insert("has_permission", user, "admin", repo);
// Delete old facts
tx.Delete("has_role", user, "maintainer", repo);
tx.Delete("has_role", user, "member", org);
});{
"message": "<string>"
}{
"message": "<string>"
}Authorizations
Requires an API key to access.
Body
application/json
- Option 1
- Option 2
A grouped run of facts to insert or delete. Inserted facts must contain concrete fact args, but deleted facts may contain wildcards.
Show child attributes
Show child attributes
Response
Was this page helpful?
⌘I