// SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";
package pubsub.proto.v1;

service PubSubService {
  rpc OpenChannel(stream Message) returns (stream Message) {}
}

message Subscribe {
  AgentId source = 1;
  AgentId name = 2;
}

message Unsubscribe {
  AgentId source = 1;
  AgentId name = 2;
}

message Publish {
  AgentId source = 1;
  AgentId name = 2;
  uint32 fanout = 3;
  Content msg = 4;
}

message AgentGroup {
  uint64 organization = 1;
  uint64 namespace = 2;
}

message AgentClass {
  AgentGroup group = 1;
  uint64 class = 2;
}

message AgentId {
  AgentClass class = 1;
  optional uint64 id = 2;
}

message Content {
  string contentType = 1;
  bytes blob = 2;
}

message Message {
  oneof messageType {
    Subscribe subscribe = 1;
    Unsubscribe unsubscribe = 2;
    Publish publish = 3;
  }
  map<string, string> metadata = 4;
}
