syntax = "proto3";

import "google/protobuf/wrappers.proto";
import "google/api/annotations.proto";

package com.wixpress.iptf.webhooks;

service WebhooksKV {
  rpc queryApp(QueryAppRequest) returns (QueryAppResponse){
    option (google.api.http) = {};
  };

  rpc queryAppSecretAndPrivateKey(QueryAppSecretAndPrivateKeyRequest) returns (QueryAppSecretAndPrivateKeyResponse){
    option (google.api.http) = {};
  };
}

message QueryAppRequest {
  string app_def_id = 1;
  string version = 2;
}

message QueryAppSecretAndPrivateKeyRequest {
  string app_def_id = 1;
}

message QueryAppSecretAndPrivateKeyResponse {
  google.protobuf.StringValue private_key = 1;
  string secret = 2;
}

message QueryAppResponse {
  repeated string permissions = 1;
  google.protobuf.StringValue private_key = 2;
  string secret = 3;
  repeated DispatcherAppWebhook webhook = 4;
}

message DispatcherAppWebhook {
    string webhookSlug = 1;
    string callback_url = 2;
}