syntax = "proto3";

package ory.keto.relation_tuples.v1alpha2;

import "ory/keto/relation_tuples/v1alpha2/relation_tuples.proto";

option csharp_namespace = "Ory.Keto.RelationTuples.v1alpha2";
option go_package = "github.com/ory/keto/proto/ory/keto/relation_tuples/v1alpha2;rts";
option java_multiple_files = true;
option java_outer_classname = "ReadServiceProto";
option java_package = "sh.ory.keto.relation_tuples.v1alpha2";
option php_namespace = "Ory\\Keto\\RelationTuples\\v1alpha2";

// The service to query relationships.
//
// This service is part of the read-APIs.
service ReadService {
  // Lists ACL relationships.
  rpc ListRelationTuples(ListRelationTuplesRequest) returns (ListRelationTuplesResponse);
}

// Request for ReadService.ListRelationTuples RPC. See
// ListRelationTuplesRequest.Query for how to filter the query.
message ListRelationTuplesRequest {
  // Deprecated. All query constraints are concatenated with a logical AND
  // operator. The RelationTuple list from ListRelationTuplesResponse is
  // ordered from the newest RelationTuple to the oldest.
  Query query = 1 [deprecated = true];

  // The query describing which relation tuples to list.
  RelationQuery relation_query = 2;

  // This field is not implemented yet and has no effect.
  string snaptoken = 3;

  // Optional. The maximum number of RelationTuples to return in the response.
  // Default: 100
  int32 page_size = 4;

  // Optional. An opaque pagination token returned from a previous call to
  // ListRelationTuples that indicates where the page should start at. An empty
  // token denotes the first page. All successive pages require the token from
  // the previous page.
  string page_token = 5;

  // The query for listing relationships. Clients can specify any optional field
  // to partially filter for specific relationships.
  message Query {
    // The namespace this relation tuple lives in.
    string namespace = 1;
    // The object related by this tuple.
    string object = 2;
    // The relation between an Object and a Subject.
    string relation = 3;
    // The subject related by this tuple.
    Subject subject = 4;
  }
}

// The response of a ReadService.ListRelationTuples RPC.
message ListRelationTuplesResponse {
  // The relationships matching the list request.
  repeated RelationTuple relation_tuples = 1;
  // The token required to get the next page. If this is the last page, the
  // token will be the empty string.
  string next_page_token = 2;
}
