// Copyright 2022 Flower Labs GmbH. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ==============================================================================

syntax = "proto3";

package flwr.proto;

import "flwr/proto/node.proto";
import "flwr/proto/task.proto";
import "flwr/proto/run.proto";

service Driver {
  // Request run_id
  rpc CreateRun(CreateRunRequest) returns (CreateRunResponse) {}

  // Return a set of nodes
  rpc GetNodes(GetNodesRequest) returns (GetNodesResponse) {}

  // Create one or more tasks
  rpc PushTaskIns(PushTaskInsRequest) returns (PushTaskInsResponse) {}

  // Get task results
  rpc PullTaskRes(PullTaskResRequest) returns (PullTaskResResponse) {}

  // Get run details
  rpc GetRun(GetRunRequest) returns (GetRunResponse) {}
}

// CreateRun
message CreateRunRequest {
  string fab_id = 1;
  string fab_version = 2;
}
message CreateRunResponse { sint64 run_id = 1; }

// GetNodes messages
message GetNodesRequest { sint64 run_id = 1; }
message GetNodesResponse { repeated Node nodes = 1; }

// PushTaskIns messages
message PushTaskInsRequest { repeated TaskIns task_ins_list = 1; }
message PushTaskInsResponse { repeated string task_ids = 2; }

// PullTaskRes messages
message PullTaskResRequest {
  Node node = 1;
  repeated string task_ids = 2;
}
message PullTaskResResponse { repeated TaskRes task_res_list = 1; }
