syntax = "proto3";

package dapr;

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

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

option csharp_namespace = "Dapr.Client.Grpc";


// Dapr definitions
service Dapr {
  rpc PublishEvent(PublishEventEnvelope) returns (google.protobuf.Empty) {}
  rpc InvokeService(InvokeServiceEnvelope) returns (InvokeServiceResponseEnvelope) {}
  rpc InvokeBinding(InvokeBindingEnvelope) returns (google.protobuf.Empty) {}
  rpc GetState(GetStateEnvelope) returns (GetStateResponseEnvelope) {}
  rpc SaveState(SaveStateEnvelope) returns (google.protobuf.Empty) {}
  rpc DeleteState(DeleteStateEnvelope) returns (google.protobuf.Empty) {}
}

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

message DeleteStateEnvelope {
  string key = 1;
  string etag = 2;
  StateOptions options = 3;
}

message SaveStateEnvelope {
  repeated StateRequest requests = 1;
}

message GetStateEnvelope {
    string key = 1;
    string consistency = 2;   
}

message GetStateResponseEnvelope {
  google.protobuf.Any data = 1;
  string etag = 2;
}

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

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

message PublishEventEnvelope {
    string topic = 1;
    google.protobuf.Any data = 2;
}

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;
}

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

message StateRequestOptions {
  string concurrency = 1;
  string consistency = 2;
  StateRetryPolicy retryPolicy = 3;
}

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