syntax = "proto3";

// If you make any changes make sure you run: make regenerate-proto

package gitlab.agent.kubernetes_api.watch_aggregator;

option go_package = "gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v18/internal/module/kubernetes_api/server/watch_aggregator";

import "buf/validate/validate.proto";

message WatchRequest {
  option (buf.validate.message).cel = {
    id: "watch_params_required_for_watch",
    message: "watch_params is required for type == watch",
    expression: "!(this.type == 'watch' && !has(this.watch_params))"
  };

  string watch_id = 1 [json_name = "watch_id", (buf.validate.field).string.min_bytes = 1];
  string type = 2 [
    json_name = "type",
    (buf.validate.field).string.in = "watch",
    (buf.validate.field).string.in = "unwatch"
  ];
  WatchParams watch_params = 3 [json_name = "watch_params"];
}

message WatchParams {
  string group = 1 [json_name = "group"];
  string version = 2 [json_name = "version", (buf.validate.field).string.min_bytes = 1];
  string resource = 3 [json_name = "resource", (buf.validate.field).string.min_bytes = 1];
  string namespace = 4 [json_name = "namespace"];
  // see https://kubernetes.io/docs/reference/kubernetes-api/common-parameters/common-parameters/#resourceVersion
  optional string resource_version = 5 [json_name = "resource_version"];
  // see https://kubernetes.io/docs/reference/kubernetes-api/common-parameters/common-parameters/#allowWatchBookmarks
  optional bool allow_watch_bookmarks = 6 [json_name = "allow_watch_bookmarks"];
  // see https://kubernetes.io/docs/reference/kubernetes-api/common-parameters/common-parameters/#sendInitialEvents
  optional bool send_initial_events = 7 [json_name = "send_initial_events"];
  // see https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
  optional string field_selector = 8 [json_name = "field_selector"];
  // see https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering
  optional string label_selector = 9 [json_name = "label_selector"];
}
