syntax = "proto3";

package it0.inventory;

service InventoryService {
  rpc GetServer (GetServerRequest) returns (ServerResponse);
  rpc ListServers (ListServersRequest) returns (ListServersResponse);
  rpc GetCredential (GetCredentialRequest) returns (CredentialResponse);
  rpc GetTemporaryCredential (GetTemporaryCredentialRequest) returns (TemporaryCredentialResponse);
}

message GetServerRequest {
  string server_id = 1;
}

message ServerResponse {
  string id = 1;
  string name = 2;
  string host = 3;
  int32 port = 4;
  string environment = 5;
  string role = 6;
  string ssh_user = 7;
  string credential_id = 8;
  string network_type = 9;
  string jump_server_id = 10;
}

message ListServersRequest {
  string environment = 1;
  string cluster_id = 2;
}

message ListServersResponse {
  repeated ServerResponse servers = 1;
}

message GetCredentialRequest {
  string credential_id = 1;
}

message CredentialResponse {
  string id = 1;
  string type = 2;
  bytes decrypted_value = 3;
}

message GetTemporaryCredentialRequest {
  string credential_id = 1;
  int32 ttl_seconds = 2;
}

message TemporaryCredentialResponse {
  string temp_path = 1;
  string expires_at = 2;
}
