syntax = "proto3";

package daprclient;

import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/duration.proto";

option java_outer_classname = "DaprClientProtos";
option java_package = "io.dapr";

// User Code definitions
service DaprClient {
  rpc OnInvoke (InvokeEnvelope) returns (google.protobuf.Any) {}
  rpc GetTopicSubscriptions(google.protobuf.Empty) returns (GetTopicSubscriptionsEnvelope) {}
  rpc GetBindingsSubscriptions(google.protobuf.Empty) returns (GetBindingsSubscriptionsEnvelope) {}
  rpc OnBindingEvent(BindingEventEnvelope) returns (BindingResponseEnvelope) {}
  rpc OnTopicEvent(CloudEventEnvelope) returns (google.protobuf.Empty) {}
}

message CloudEventEnvelope {
  string id = 1;
  string source = 2;
  string type = 3;
  string specVersion = 4;
  string dataContentType = 5;
  string topic = 6;
  google.protobuf.Any data = 7;
}

message BindingEventEnvelope {
    string name = 1;
    google.protobuf.Any data = 2;
    map<string,string> metadata = 3;
}

message BindingResponseEnvelope {
  google.protobuf.Any data = 1;
  repeated string to = 2;
  repeated State state = 3;
  string concurrency = 4;
}

message InvokeEnvelope {
    string method = 1;
    google.protobuf.Any data = 2;
    map<string,string> metadata = 3;
}

message GetTopicSubscriptionsEnvelope {
  repeated string topics = 1;
}

message GetBindingsSubscriptionsEnvelope {
  repeated string bindings = 1;
}

message State {
  string key = 1;
  google.protobuf.Any value = 2;
  string etag = 3;
  map<string,string> metadata = 4;
  StateOptions options = 5;
}

message StateOptions {
  string concurrency = 1;
  string consistency = 2;
  RetryPolicy retryPolicy = 3;
}

message RetryPolicy {
  int32 threshold = 1;
  string pattern = 2;
  google.protobuf.Duration interval = 3;
}
