syntax = "proto3";

package integration.v1;

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

option go_package = "github.com/tidbcloud/metrics-integration/regional/api/integration/v1";

message ApplyIntegrationRequest {
  string helm_config = 2;
}

message UninstallIntegrationRequest {
  string helm_config = 2;
}

message IntegrationStatusResp {
  string status = 1; // Status of the integration (e.g., "active", "inactive", "error")
  string message = 2; // Additional message or error details
}

message CreateMetricsKeyRequest {
  string hashed_metrics_key = 1;
  string cluster_id = 2;
  string cluster_config_map = 3;
}

message DeleteMetricsKeyRequest {
  string hashed_metrics_key = 1;
  string cluster_id = 2;
  string cluster_config_map = 3;
}

message ScaleClusterRequest {
  string cluster_id = 1;
  string cluster_config_map = 2;
}

message DeleteClusterRequest {
  string cluster_id = 1;
}

message DedicatedCPURefreshComponent {
  string component_type = 1;
  int64 cpu_num = 2;
}

message RefreshDedicatedClusterCPUConfigRequest {
  string pipeline_id = 1;
  repeated DedicatedCPURefreshComponent components = 2;
}

// IntegrationService defines CRUD interfaces for Integration
service IntegrationService {
  rpc ApplyIntegration(ApplyIntegrationRequest) returns (IntegrationStatusResp) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/apply"
      body: "*"
    };
  }

  rpc UninstallIntegration(UninstallIntegrationRequest) returns (IntegrationStatusResp) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/uninstall"
      body: "*"
    };
  }

  rpc CreateMetricsKey(CreateMetricsKeyRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/metrics-key/create"
      body: "*"
    };
  }

  rpc DeleteMetricsKey(DeleteMetricsKeyRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/metrics-key/delete"
      body: "*"
    };
  }

  rpc ScaleCluster(ScaleClusterRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/metrics-key/scale"
      body: "*"
    };
  }

  rpc DeleteCluster(DeleteClusterRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/metrics-key/cluster-delete"
      body: "*"
    };
  }

  rpc RefreshDedicatedClusterCPUConfig(RefreshDedicatedClusterCPUConfigRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/metrics-integration-regional/api/v1/pipeline/dedicated-cpu"
      body: "*"
    };
  }
}
