syntax = "proto3";

package svc.localhost.v1;

import "types/v1/localhost_config.proto";
import "types/v1/meta.proto";
import "types/v1/organization.proto";
import "types/v1/user.proto";
import "types/v1/version.proto";

option go_package = "svc/localhost/v1;localhostv1";

service LocalhostService {
  rpc Ping(PingRequest) returns (PingResponse);
  rpc DoLogin(DoLoginRequest) returns (DoLoginResponse);
  rpc DoLogout(DoLogoutRequest) returns (DoLogoutResponse);
  rpc DoUpdate(DoUpdateRequest) returns (DoUpdateResponse);
  rpc DoRestart(DoRestartRequest) returns (DoRestartResponse);

  rpc GetConfig(GetConfigRequest) returns (GetConfigResponse);
  rpc SetConfig(SetConfigRequest) returns (SetConfigResponse);
}

message PingRequest {}
message PingResponse {
  message UserDetails {
    types.v1.User user = 1;
    types.v1.Organization current_organization = 2;
    types.v1.Organization default_organization = 3;
  }

  types.v1.Version client_version = 1;
  string architecture = 2;
  string operating_system = 3;
  // logged_in_user is set if the CLI is logged in.
  // if the CLI is alive but not logged in, this field
  // is null
  UserDetails logged_in_user = 4;
  types.v1.ResMeta meta = 1000;
}

message DoLoginRequest {
  string returnToURL = 1;
}
message DoLoginResponse {}

message DoLogoutRequest {
  string returnToURL = 1;
}
message DoLogoutResponse {}

message DoUpdateRequest {}
message DoUpdateResponse {}

message DoRestartRequest {}
message DoRestartResponse {}

message GetConfigRequest {}
message GetConfigResponse {
  types.v1.LocalhostConfig config = 1;
}

message SetConfigRequest {
  types.v1.LocalhostConfig config = 1;
}
message SetConfigResponse {}
