1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16syntax = "proto3";
17
18package tradefed.device.server;
19
20option java_package = "com.proto.tradefed.device";
21option java_outer_classname = "TradefedDeviceService";
22option java_multiple_files = true;
23option java_generic_services = true;
24
25// The Tradefed device service provides TF device management functions.
26service DeviceManagement {
27  // Reserve a device.
28  rpc ReserveDevice(ReserveDeviceRequest) returns (ReserveDeviceResponse) {}
29  // Release a reservation.
30  rpc ReleaseReservation(ReleaseReservationRequest)
31      returns (ReleaseReservationResponse) {}
32  // Get the devices status
33  rpc GetDevicesStatus(GetDevicesStatusRequest)
34      returns (GetDevicesStatusResponse) {}
35  // Apply to stop leasing tests. The RPC returns immediately and doesn't wait
36  // for all leasing being stopped.
37  rpc StopLeasing(StopLeasingRequest) returns (StopLeasingResponse) {}
38}
39
40// The request of stopping leasing tests.
41message StopLeasingRequest {}
42
43// The response of stopping leasing tests.
44message StopLeasingResponse {
45  enum Result {
46    UNKNOWN = 0;
47    SUCCEED = 1;
48    FAIL = 2;
49  }
50  Result result = 1;
51  string message = 2;
52}
53
54// The request to reserve device.
55message ReserveDeviceRequest {
56  // The identifier of the device to be reserved.
57  string device_id = 1;
58}
59
60// The response of reserving device.
61message ReserveDeviceResponse {
62  enum Result {
63    // The default value
64    UNKNOWN = 0;
65    // The reservation succeed.
66    SUCCEED = 1;
67    // The device has been reserved by other RPC calls.
68    ALREADY_RESERVED = 2;
69    // The devive has been allocated but not via the RPC call.
70    ALREADY_ALLOCATED = 3;
71    // The device is abnormal and cannot run tests.
72    UNAVAILABLE = 4;
73  }
74  Result result = 1;
75  // A unique identifier to track the reservation
76  string reservation_id = 2;
77  // In case of error, this can contain debugging reason
78  string message = 3;
79}
80
81// The request to release reservation
82message ReleaseReservationRequest {
83  // Unique identifier tracking the reservation
84  string reservation_id = 1;
85}
86
87// The response of releasing reservation
88message ReleaseReservationResponse {
89  enum Result {
90    UNKNOWN = 0;
91    // Succeed to release reservation
92    SUCCEED = 1;
93    // Fail to release reservation because it does not exist
94    RESERVATION_NOT_EXIST = 2;
95    // Fail to release reservation because the device is still in use
96    DEVICE_IN_USE = 3;
97  }
98  Result result = 1;
99  // In case of error, this can contain debugging reason
100  string message = 2;
101}
102
103// The request to get status of devices
104message GetDevicesStatusRequest {
105  // Request devices status. if left empty, all devices status are returned.
106  repeated string device_id = 1;
107}
108
109message GetDevicesStatusResponse {
110  repeated DeviceStatus device_status = 1;
111}
112
113// Representation of a device and its reservation status
114message DeviceStatus {
115  enum ReservationStatus {
116    UNKNOWN = 0;
117    // Device can be reserved
118    READY = 1;
119    // Device has been reserved via the RPC service
120    RESERVED = 2;
121    // The devive has been allocated but not via the RPC call.
122    ALLOCATED = 3;
123    // The device is abnormal and cannot run tests.
124    UNAVAILABLE = 4;
125  }
126  string device_id = 1;
127  ReservationStatus reservation_status = 2;
128  // the run target of the device used for scheduling purpose, default to product board
129  // but can be customized via TF global host config files
130  string run_target = 3;
131}
132