// https://git-aws.internal.justin.tv/systems/provisioner

syntax = "proto3";

package code_justin_tv.rhys.nursery.ext.provisioner.v1_0;
option go_package = "provisioner_v1_0";

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

service Provisioner {
  rpc ListDevices (ListDevicesRequest) returns (ListDevicesResponse) {
    option (google.api.http) = { get: "/api/1.0/devices" };
  }

  rpc ListRacks (ListRacksRequest) returns (ListRacksResponse) {
    option (google.api.http) = { get: "/api/1.0/racks/**" };
  }
  rpc GetRack (GetRackRequest) returns (Rack) {
    option (google.api.http) = { get: "/api/1.0/racks/{rack_id}/**" };
  }
  rpc GetRackDetails (GetRackRequest) returns (Rack) {
    option (google.api.http) = { get: "/api/1.0/racks/{rack_id}/details" };
  }
  rpc GetRackByName (GetRackByNameRequest) returns (Rack) {
    option (google.api.http) = { get: "/api/1.0/racks/{building}/{name}/**" };
  }
  rpc CreateRack (CreateRackRequest) returns (Rack) {
    option (google.api.http) = { put: "/api/1.0/racks/**" };
  }
  rpc DeleteRack (DeleteRackRequest) returns (Rack) {
    option (google.api.http) = { delete: "/api/1.0/racks/{rack_id}/**" };
  }
}

message ListDevicesRequest {
  int32 limit = 1;
  string filter = 2;
}

message ListDevicesResponse {
  int32 count = 1 [json_name="Count"];
  repeated Device device = 2 [json_name="Devices"];
}

message Device {
  string uuid = 1;
  string name = 2;
  string macaddress = 3;
  int32 device_id = 4;

  string blade_serial_no = 5;
  string chassis_serial_no = 6;
  string cpucore = 7;
  string cpucount = 8;
  string device_type = 9;
  string in_service = 10;
  string ip = 11;
  string ip_label = 12;
  int32 last_updated = 13;
  string rack_name = 14;
  string ram = 15;
  string state = 16;
  int32 to_install = 17;

  google.protobuf.Value expires_on = 18;
  google.protobuf.Value reserved_by = 19;
  google.protobuf.Value reserved_for = 20;
}

message ListRacksRequest {
}

message ListRacksResponse {
  repeated Rack rack = 1 [json_name="Racks"];
}

message Rack {
  int32 rack_id = 1;
  string name = 2;

  int32 available_u = 3;
  string building = 4;
  int32 first_number = 5;
  int32 rack_size = 6;
  string rack_url = 7;
  string room = 8;

  // asset_no
  // notes
  // number_start_from_bottom
  // row_name

  // chassis
}

message GetRackRequest {
  int32 rack_id = 1;
}

message GetRackByNameRequest {
  string building = 1;
  string name = 2;
}

message CreateRackRequest {
  int32 rack_id = 1; // when rack_id is set, the call will update the existing rack
  string name = 2;

  int32 available_u = 3;
  string building = 4;
  int32 first_number = 5;
  int32 rack_size = 6;
  string rack_url = 7;
  string room = 8;
}

message DeleteRackRequest {
  int32 rack_id = 1;
}
