syntax = "proto3";

package mesh;

option go_package = "atlassian.com/bitbucket/mesh/rpc";
option java_multiple_files = true;
option java_outer_classname = "CapabilityProtos";
option java_package = "com.atlassian.bitbucket.mesh.rpc";

/* CapabilityService/GetCapabilities allows clients to detect what capabilities the Mesh server provides, and allow
   the client to interop with different versions of Mesh.

   RpcApiCapability is the most important capability in this respect. The server may provide multiple RpcApiCapability
   capabilities, each describing a range of supported versions. For instance, if a v1 and v2 API is supported at the
   same time, one RpcApiCapability could describe compatibility with [1.0, 1.47] and another with [2.0, 2.8].

   If any Mesh release updates any part of the RPC API, the supported API range MUST be updated to allow clients to
   detect whether a particular RPC method is available or not, and update their interaction with Mesh accordingly.

  IMPORTANT: CapabilityService itself is NOT versioned. This means that any change to CapabilityService MUST be
             backwards compatible. New capability types may be added and new optional fields can be added to existing
             capabilities, but care must be taken not to violate the assumptions older clients may have.
 */
service CapabilityService {

  rpc GetCapabilities(RpcGetCapabilitiesRequest) returns (RpcGetCapabilitiesResponse);
}

/* Supported API version range. Any API version greater than or equal to min_version and
   less than or equal to max_version is supported. */
message RpcApiCapability {
  //Lowest supported API version
  string min_version = 1;
  //Highest supported API version
  string max_version = 2;
}

message RpcCapability {
  oneof capability_oneof {
    RpcApiCapability supported_api_versions = 1;
  }
}

message RpcGetCapabilitiesRequest {
}

message RpcGetCapabilitiesResponse {
  repeated RpcCapability capabilities = 1;
}
