@@ -99,6 +99,31 @@ service PermissionsService {
9999 body : "*"
100100 };
101101 }
102+
103+ // ImportBulkRelationships is a faster path to writing a large number of
104+ // relationships at once. It is both batched and streaming. For maximum
105+ // performance, the caller should attempt to write relationships in as close
106+ // to relationship sort order as possible: (resource.object_type,
107+ // resource.object_id, relation, subject.object.object_type,
108+ // subject.object.object_id, subject.optional_relation)
109+ rpc ImportBulkRelationships (stream ImportBulkRelationshipsRequest )
110+ returns (ImportBulkRelationshipsResponse ) {
111+ option (google.api.http ) = {
112+ post : "/v1/experimental/relationships/bulkimport"
113+ body : "*"
114+ };
115+ }
116+
117+ // ExportBulkRelationships is the fastest path available to exporting
118+ // relationships from the server. It is resumable, and will return results
119+ // in an order determined by the server.
120+ rpc ExportBulkRelationships (ExportBulkRelationshipsRequest )
121+ returns (stream ExportBulkRelationshipsResponse ) {
122+ option (google.api.http ) = {
123+ post : "/v1/experimental/relationships/bulkexport"
124+ body : "*"
125+ };
126+ }
102127}
103128
104129// Consistency will define how a request is handled by the backend.
@@ -628,4 +653,49 @@ message ResolvedSubject {
628653
629654 // partial_caveat_info holds information of a partially-evaluated caveated response
630655 PartialCaveatInfo partial_caveat_info = 3 [ (validate.rules ) .message.required = false ];
631- }
656+ }
657+
658+ // ImportBulkRelationshipsRequest represents one batch of the streaming
659+ // ImportBulkRelationships API. The maximum size is only limited by the backing
660+ // datastore, and optimal size should be determined by the calling client
661+ // experimentally.
662+ message ImportBulkRelationshipsRequest {
663+ repeated Relationship relationships = 1
664+ [ (validate.rules ).repeated .items .message.required = true ];
665+ }
666+
667+ // ImportBulkRelationshipsResponse is returned on successful completion of the
668+ // bulk load stream, and contains the total number of relationships loaded.
669+ message ImportBulkRelationshipsResponse {
670+ uint64 num_loaded = 1 ;
671+ }
672+
673+ // ExportBulkRelationshipsRequest represents a resumable request for
674+ // all relationships from the server.
675+ message ExportBulkRelationshipsRequest {
676+ Consistency consistency = 1 ;
677+
678+ // optional_limit, if non-zero, specifies the limit on the number of
679+ // relationships the server can return in one page. By default, the server
680+ // will pick a page size, and the server is free to choose a smaller size
681+ // at will.
682+ uint32 optional_limit = 2 [(validate.rules ).uint32 = {gte :0 }];
683+
684+ // optional_cursor, if specified, indicates the cursor after which results
685+ // should resume being returned. The cursor can be found on the
686+ // BulkExportRelationshipsResponse object.
687+ Cursor optional_cursor = 3 ;
688+
689+ // optional_relationship_filter, if specified, indicates the
690+ // filter to apply to each relationship to be exported.
691+ RelationshipFilter optional_relationship_filter = 4 ;
692+ }
693+
694+ // ExportBulkRelationshipsResponse is one page in a stream of relationship
695+ // groups that meet the criteria specified by the originating request. The
696+ // server will continue to stream back relationship groups as quickly as it can
697+ // until all relationships have been transmitted back.
698+ message ExportBulkRelationshipsResponse {
699+ Cursor after_result_cursor = 1 ;
700+ repeated Relationship relationships = 2 ;
701+ }
0 commit comments