sul3
01/30/2024, 11:00 AMschema
, line 1, column 1: Unexpected token at root level: TokenTypeIdentifier
This is the code I am using to pass it to the api
java
private static void createSchema() {
String schema = "";
try {
schema = new String(Files.readAllBytes(Paths.get("schemas_example/final.yaml")));
} catch (IOException e) {
e.printStackTrace();
}
WriteSchemaRequest request = WriteSchemaRequest.newBuilder()
.setSchema(schema)
.build();
try {
WriteSchemaResponse response = schemaService.writeSchema(request);
System.out.println(response.toString());
} catch (Exception e) {
System.out.println("Failed to write schema: " + e.getMessage());
}
}
Is there a special way I should be parsing this or maybe a different API function?
the schema starts with
schema: |-
as it does when I download it from the playground
I see there is a bulk import relationships, but I am looking for something where I could just pass the file if possiblevroldanbet
01/30/2024, 11:12 AMWriteSchema
. You need to extract the schema
field, that's what you want to put in WriteSchemaRequest.Schema
vroldanbet
01/30/2024, 11:12 AMspicedb server
command, thoughvroldanbet
01/30/2024, 11:13 AMsul3
01/30/2024, 11:14 AMsul3
01/30/2024, 11:15 AMvroldanbet
01/30/2024, 11:20 AMWriteSchema
and it is in fact expect to be that way. If you miss any definitions, they will be considered deleted from the schemasul3
01/30/2024, 11:21 AMsul3
01/30/2024, 11:27 AMvroldanbet
01/30/2024, 11:29 AM--boostrap
flags to start it up with the schema and rels from the YAML filevroldanbet
01/30/2024, 11:30 AMzed
command line to run a one-off command, as it understands the playground YAML and can write the schema and relationships for youvroldanbet
01/30/2024, 11:31 AMUse: "import <url>",
Short: "import schema and relationships from a file or url",
Example: `
From a gist:
zed import https://gist.github.com/ecordell/8e3b613a677e3c844742cf24421c08b6
From a playground link:
zed import https://play.authzed.com/s/iksdFvCtvnkR/schema
From pastebin:
zed import https://pastebin.com/8qU45rVK
From a devtools instance:
zed import https://localhost:8443/download
From a local file (with prefix):
zed import file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml
From a local file (no prefix):
zed import authzed-x7izWU8_2Gw3.yaml
Only schema:
zed import --relationships=false file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml
Only relationships:
zed import --schema=false file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml
With schema definition prefix:
zed import --schema-definition-prefix=mypermsystem file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml
vroldanbet
01/30/2024, 11:32 AMsul3
01/30/2024, 11:32 AMsul3
01/30/2024, 11:32 AMsul3
01/30/2024, 11:55 AMvroldanbet
01/30/2024, 12:36 PMsul3
01/30/2024, 12:38 PM