xref: /aosp_15_r20/external/googleapis/google/devtools/testing/v1/direct_access_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.devtools.testing.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/devtools/testing/v1/adb_service.proto";
24import "google/devtools/testing/v1/test_execution.proto";
25import "google/protobuf/duration.proto";
26import "google/protobuf/empty.proto";
27import "google/protobuf/field_mask.proto";
28import "google/protobuf/timestamp.proto";
29
30option go_package = "google.golang.org/genproto/googleapis/devtools/testing/v1;testing";
31option java_multiple_files = true;
32option java_outer_classname = "DirectAccessServiceProto";
33option java_package = "com.google.devtools.testing.v1";
34
35// A service for allocating devices and interacting with the live-allocated
36// devices.
37//
38// This service is part of Firebase Test Lab. To learn about how to use the
39// product, and how to integrate it with your system,
40// visit https://firebase.google.com/docs/test-lab.
41//
42// Each Session will wait for available capacity, at a higher
43// priority over Test Execution. When allocated, the session will be exposed
44// through a stream for integration.
45//
46// DirectAccessService is currently available as a preview to select developers.
47// You can register today on behalf of you and your team at
48// https://developer.android.com/studio/preview/android-device-streaming
49service DirectAccessService {
50  option (google.api.default_host) = "testing.googleapis.com";
51  option (google.api.oauth_scopes) =
52      "https://www.googleapis.com/auth/cloud-platform";
53
54  // POST /v1/projects/{project_id}/deviceSessions
55  rpc CreateDeviceSession(CreateDeviceSessionRequest) returns (DeviceSession) {
56    option (google.api.http) = {
57      post: "/v1/{parent=projects/*}/deviceSessions"
58      body: "device_session"
59    };
60    option (google.api.method_signature) = "parent,device_session";
61  }
62
63  // GET /v1/projects/{project_id}/deviceSessions
64  // Lists device Sessions owned by the project user.
65  rpc ListDeviceSessions(ListDeviceSessionsRequest)
66      returns (ListDeviceSessionsResponse) {
67    option (google.api.http) = {
68      get: "/v1/{parent=projects/*}/deviceSessions"
69    };
70    option (google.api.method_signature) = "parent";
71  }
72
73  // GET /v1/projects/{project_id}/deviceSessions/{device_session_id}
74  // Return a DeviceSession, which documents the allocation status and
75  // whether the device is allocated. Clients making requests from this API
76  // must poll GetDeviceSession.
77  rpc GetDeviceSession(GetDeviceSessionRequest) returns (DeviceSession) {
78    option (google.api.http) = {
79      get: "/v1/{name=projects/*/deviceSessions/*}"
80    };
81    option (google.api.method_signature) = "name";
82  }
83
84  // POST
85  // /v1/projects/{project_id}/deviceSessions/{device_session_id}:cancel
86  // Changes the DeviceSession to state FINISHED and terminates all connections.
87  // Canceled sessions are not deleted and can be retrieved or
88  // listed by the user until they expire based on the 28 day deletion policy.
89  rpc CancelDeviceSession(CancelDeviceSessionRequest)
90      returns (google.protobuf.Empty) {
91    option (google.api.http) = {
92      post: "/v1/{name=projects/*/deviceSessions/*}:cancel"
93      body: "*"
94    };
95  }
96
97  // PATCH
98  // /v1/projects/{projectId}/deviceSessions/deviceSessionId}:updateDeviceSession
99  // Updates the current device session to the fields described by the
100  // update_mask.
101  rpc UpdateDeviceSession(UpdateDeviceSessionRequest) returns (DeviceSession) {
102    option (google.api.http) = {
103      patch: "/v1/{device_session.name=projects/*/deviceSessions/*}"
104      body: "device_session"
105    };
106    option (google.api.method_signature) = "device_session,update_mask";
107  }
108
109  // Exposes ADB connection for use with the Adb Device Forwarder project
110  // if the reserved device supports ADB.
111  // gRPC headers are used to authenticate the Connect RPC, as well as
112  // associate to a particular device session.
113  // In particular, the user must specify the "X-FTL-Session-Name" header.
114  rpc AdbConnect(stream AdbMessage) returns (stream DeviceMessage) {}
115}
116
117// A Request for the device session from the session service.
118message CreateDeviceSessionRequest {
119  // Required. The Compute Engine project under which this device will be
120  // allocated. "projects/{project_id}"
121  string parent = 1 [
122    (google.api.field_behavior) = REQUIRED,
123    (google.api.resource_reference) = {
124      type: "cloudresourcemanager.googleapis.com/Project"
125    }
126  ];
127
128  // Required. A device session to create.
129  DeviceSession device_session = 2 [(google.api.field_behavior) = REQUIRED];
130}
131
132// Request a list of device sessions in the provided parent matching the given
133// filter.
134message ListDeviceSessionsRequest {
135  // Required. The name of the parent to request, e.g. "projects/{project_id}"
136  string parent = 4 [
137    (google.api.field_behavior) = REQUIRED,
138    (google.api.resource_reference) = {
139      type: "cloudresourcemanager.googleapis.com/Project"
140    }
141  ];
142
143  // Optional. The maximum number of DeviceSessions to return.
144  int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
145
146  // Optional. A continuation token for paging.
147  string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
148
149  // Optional. If specified, responses will be filtered by the given filter.
150  // Allowed fields are: session_state.
151  string filter = 3 [(google.api.field_behavior) = OPTIONAL];
152}
153
154// A list of device sessions.
155message ListDeviceSessionsResponse {
156  // The sessions matching the specified filter in the given cloud project.
157  repeated DeviceSession device_sessions = 1;
158
159  // A token, which can be sent as `page_token` to retrieve the next page.
160  // If this field is omitted, there are no subsequent pages.
161  string next_page_token = 2;
162}
163
164// The request object for a Device Session.
165message GetDeviceSessionRequest {
166  // Required. Name of the DeviceSession, e.g.
167  // "projects/{project_id}/deviceSessions/{session_id}"
168  string name = 1 [
169    (google.api.field_behavior) = REQUIRED,
170    (google.api.resource_reference) = {
171      type: "testing.googleapis.com/DeviceSession"
172    }
173  ];
174}
175
176// The request object for cancelling a Device Session.
177message CancelDeviceSessionRequest {
178  // Required. Name of the DeviceSession, e.g.
179  // "projects/{project_id}/deviceSessions/{session_id}"
180  string name = 1 [
181    (google.api.field_behavior) = REQUIRED,
182    (google.api.resource_reference) = {
183      type: "testing.googleapis.com/DeviceSession"
184    }
185  ];
186}
187
188// The request object for the UpdateDeviceSession RPC.
189message UpdateDeviceSessionRequest {
190  // Required. DeviceSession to update.
191  // The device session's `name` field is used to identify the session to update
192  // "projects/{project_id}/deviceSessions/{session_id}"
193  DeviceSession device_session = 1 [(google.api.field_behavior) = REQUIRED];
194
195  // Required. The list of fields to update.
196  google.protobuf.FieldMask update_mask = 2
197      [(google.api.field_behavior) = REQUIRED];
198}
199
200// Protobuf message describing the device message, used from several RPCs.
201message DeviceSession {
202  option (google.api.resource) = {
203    type: "testing.googleapis.com/DeviceSession"
204    pattern: "projects/{project}/deviceSessions/{session}"
205  };
206
207  // The state that the device session resides.
208  enum SessionState {
209    // Default value. This value is unused.
210    SESSION_STATE_UNSPECIFIED = 0;
211
212    // Initial state of a session request. The session is being validated for
213    // correctness and a device is not yet requested.
214    REQUESTED = 1;
215
216    // The session has been validated and is in the queue for a device.
217    PENDING = 2;
218
219    // The session has been granted and the device is accepting
220    // connections.
221    ACTIVE = 3;
222
223    // The session duration exceeded the device’s reservation time period and
224    // timed out automatically.
225    EXPIRED = 4;
226
227    // The user is finished with the session and it was canceled by the user
228    // while the request was still getting allocated or after allocation and
229    // during device usage period.
230    FINISHED = 5;
231
232    // Unable to complete the session because the device was unavailable and
233    // it failed to allocate through the scheduler. For example, a device not
234    // in the catalog was requested or the request expired in the allocation
235    // queue.
236    UNAVAILABLE = 6;
237
238    // Unable to complete the session for an internal reason, such as an
239    // infrastructure failure.
240    ERROR = 7;
241  }
242
243  // A message encapsulating a series of Session states and the time that the
244  // DeviceSession first entered those states.
245  message SessionStateEvent {
246    // Output only. The session_state tracked by this event
247    SessionState session_state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
248
249    // Output only. The time that the session_state first encountered that
250    // state.
251    google.protobuf.Timestamp event_time = 2
252        [(google.api.field_behavior) = OUTPUT_ONLY];
253
254    // Output only. A human-readable message to explain the state.
255    string state_message = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
256  }
257
258  // Optional. Name of the DeviceSession, e.g.
259  // "projects/{project_id}/deviceSessions/{session_id}"
260  string name = 1 [(google.api.field_behavior) = OPTIONAL];
261
262  // Output only. The title of the DeviceSession to be presented in the UI.
263  string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
264
265  // Output only. Current state of the DeviceSession.
266  SessionState state = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
267
268  // Output only. The historical state transitions of the session_state message
269  // including the current session state.
270  repeated SessionStateEvent state_histories = 14
271      [(google.api.field_behavior) = OUTPUT_ONLY];
272
273  oneof expiration {
274    // Optional. The amount of time that a device will be initially allocated
275    // for. This can eventually be extended with the UpdateDeviceSession RPC.
276    // Default: 15 minutes.
277    google.protobuf.Duration ttl = 13 [(google.api.field_behavior) = OPTIONAL];
278
279    // Optional. If the device is still in use at this time, any connections
280    // will be ended and the SessionState will transition from ACTIVE to
281    // FINISHED.
282    google.protobuf.Timestamp expire_time = 5
283        [(google.api.field_behavior) = OPTIONAL];
284  }
285
286  // Output only. The interval of time that this device must be interacted with
287  // before it transitions from ACTIVE to TIMEOUT_INACTIVITY.
288  google.protobuf.Duration inactivity_timeout = 7
289      [(google.api.field_behavior) = OUTPUT_ONLY];
290
291  // Output only. The time that the Session was created.
292  google.protobuf.Timestamp create_time = 8
293      [(google.api.field_behavior) = OUTPUT_ONLY];
294
295  // Output only. The timestamp that the session first became ACTIVE.
296  google.protobuf.Timestamp active_start_time = 9
297      [(google.api.field_behavior) = OUTPUT_ONLY];
298
299  // Required. The requested device
300  AndroidDevice android_device = 15 [(google.api.field_behavior) = REQUIRED];
301}
302